using DevExpress.LookAndFeel;
using DevExpress.Utils;
using DevExpress.XtraBars.Docking;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraNavBar;
using DevExpress.XtraTab;
using DevExpress.XtraTabbedMdi;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows.Forms;
using System.IO;
using Microsoft.Office.Interop.Excel;//JMR -- for the excel stuff

namespace ePlanSysOman
{
    public partial class frmMain
    {
        public static frmMain start = new frmMain();
        //public static frmMain start = new frmMain();//JMR    

        public OleDbDataAdapter daCBE = new OleDbDataAdapter();
        public OleDbDataAdapter daMPRS = new OleDbDataAdapter();
        public OleDbDataAdapter daPTP = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferAssembly = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferBackShop = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferCont = new OleDbDataAdapter();
        public OleDbDataAdapter daTransfercountry = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferDrawings = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferEffectivities = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferGeneral = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferMisc = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferNotes = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferPlano = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferProgram = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferRefDes = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferRefDesComp = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferRevision = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferRoute = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferSelHarness = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferTemplate = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferTools = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferWires = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferWiresAdd = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferWiresBackshell = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferWiresRemove = new OleDbDataAdapter();
        public OleDbDataAdapter daTransferWiresRevise = new OleDbDataAdapter();
        private clsData drc = new clsData();
        private int FRMO = 0;
        public bool IsOther;
        private string PlanNumber = "";
        private string sql = "";
        private int thru = 0;
        private string typever = "";
        Thread updatethread;
        ThreadStart UpdateThreadStartPTP = new ThreadStart(PTPUPDATE);//JMR -- look at -- taking away 'this.' and making the PTPUPDATE method static fixes this problem
        ThreadStart UpdateThreadStartCBE = new ThreadStart(CBEUPDATE);
        ThreadStart UpdateThreadStartmprs = new ThreadStart(MprsUpdate);
        string GHARN = "";
        string GHARNOLD = "";
        string PLRER = "";
        string carddesc = "";
        string cardtbd = "";
        string cardnopl = "";
        string CARDTypeVer = "";
        public bool iselectrical = false;
        public bool isMKPL = false;

        //BJR
        public static frmConnection frmConn = new frmConnection();

        private void  // ERROR: Handles clauses are not supported in C#
    frmMain_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
        {
            // Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
            //For Each i As Process In pro
            //    i.Kill()
            //Next

        }
        //'Private Sub ZipFiles()

        //'    Dim zipPath As String = Application.StartupPath & "\myzip.xml"

        //'    'Open the zip file if it exists, else create a new one 
        //'    Dim zip As Package = ZipPackage.Open(zipPath, _
        //'         IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite)

        //'    'Add as many files as you like:
        //'    AddToArchive(zip, Application.StartupPath & "\Omanmain.mdb")


        //'    zip.Close() 'Close the zip file

        //'End Sub


        //'Private Sub AddToArchive(ByVal zip As Package, _
        //'                     ByVal fileToAdd As String)

        //'    'Replace spaces with an underscore (_) 
        //'    Dim uriFileName As String = fileToAdd.Replace(" ", "_")

        //'    'A Uri always starts with a forward slash "/" 
        //'    Dim zipUri As String = String.Concat("/", _
        //'               IO.Path.GetFileName(uriFileName))

        //'    Dim partUri As New Uri(zipUri, UriKind.Relative)
        //'    Dim contentType As String = _
        //'               Net.Mime.MediaTypeNames.Application.Zip

        //'    'The PackagePart contains the information: 
        //'    ' Where to extract the file when it's extracted (partUri) 
        //'    ' The type of content stream (MIME type):  (contentType) 
        //'    ' The type of compression:  (CompressionOption.Normal)   
        //'    Dim pkgPart As PackagePart = zip.CreatePart(partUri, _
        //'               contentType, CompressionOption.Normal)

        //'    'Read all of the bytes from the file to add to the zip file 
        //'    Dim bites As Byte() = file.ReadAllBytes(fileToAdd)

        //'    'Compress and write the bytes to the zip file 
        //'    pkgPart.GetStream().Write(bites, 0, bites.Length)

        //'End Sub


        //public static void Main()
        //{
        //    object sender = new object();
        //    System.EventArgs e = new System.EventArgs();
        //    frmMain start = new frmMain();

        //    try
        //    {
        //        start.frmMain_Load(sender, e);
        //    }
        //    catch
        //    {

        //    }
        //}


        // ERROR: Handles clauses are not supported in C#
        [STAThread]
        public static void Main()
        {
            
            clsData dc = new clsData();
            DataSet ds = new DataSet();

            Module1.Main2();

            //Dim dghf As New DataSet
            //dghf = dc.getData("SELECT * FROM PDFWIRE1")
            //Dim wspecOld As String
            //Dim wspecNew As String
            //For HJ = 0 To dghf.Tables(0).Rows.Count - 1

            //    wspecOld = dghf.Tables(0).Rows(HJ).Item("wspecOld")
            //    wspecNew = dghf.Tables(0).Rows(HJ).Item("wspcNew")
            //    dc.ExecuteSQL("UPDATE PTP SET WIRE_SPEC_GAGE = '" & wspecNew & "' WHERE WIRE_SPEC_GAGE='" & wspecOld & "'")
            //Next
            DataSet dsc = new DataSet();
            dc.ExecuteSQL("delete * FROM TBLPLANO WHERE PlannoId not in ( select genPlId as PlannoId from tblgeneral)");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = '-' WHERE WIRE_END_PIN is NULL");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'HI' WHERE WIRE_END_PIN ='H-I'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'LI' WHERE WIRE_END_PIN ='L-I'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'HO' WHERE WIRE_END_PIN ='H-0'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'LO' WHERE WIRE_END_PIN ='L-0'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'HO' WHERE WIRE_END_PIN ='H0'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'LO' WHERE WIRE_END_PIN ='L0'");
            dc.ExecuteSQL("UPDATE TBLASSEMBLY SET PRTECP ='-' WHERE PRTECP ='2818'");
            dc.ExecuteSQL("UPDATE cbe SET PTNUMBER = 'MS27488-20-1' WHERE PTNUMBER ='MS27488-20'");
            dc.ExecuteSQL("UPDATE cbe SET PTNUMBER = 'MS27488-22-1' WHERE PTNUMBER ='MS27488-22'");
            dc.ExecuteSQL("UPDATE cbe SET PTNUMBER = 'MS27488-16-1' WHERE PTNUMBER ='MS27488-16'");
            dc.ExecuteSQL("UPDATE tblgeneral SET genpdf2 = '2818' WHERE genpdf2 is null");
            dc.ExecuteSQL("UPDATE tblgeneral SET genpdf2 = '2818' WHERE genpdf2 ='-'");
            Module1.newModule.InitConnection();//JMR
            DataSet set2 = new DataSet();
            clsData data2 = new clsData();
            set2 = data2.getData("SELECT * FROM TBLREFDES WHERE reportnote  like '%must installed%'");
            int num94 = 0;
            if (set2.Tables.Count != 0)
            {
                num94 = (set2.Tables[0].Rows.Count - 1);
            }
            int i4 = 0;
            string rep = "";
            string cardn;
            string newrep;
            while ((i4 <= num94))
            {
                Module1.newModule.RefDes = "";
                rep = "";
                if (set2.Tables.Count != 0)
                {
                    Module1.newModule.RefDes = Conversions.ToString(set2.Tables[0].Rows[i4]["REFDES"]);//JMR
                    rep = Conversions.ToString(set2.Tables[0].Rows[i4]["reportnote"]);
                }  
                newrep = rep.Replace("Wire tie", "Install wire tie");
                newrep = newrep.Replace("must installed", "");
                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblrefdes SET reportnote ='",
          newrep,
          "' WHERE reportnote ='",
          rep,
          "'"
        }));
                i4 += 1;
            }
            set2 = data2.getData("SELECT * FROM TBLREFDES WHERE reportnote  like '%aditional%'");
            num94 = 0; // BJR
            if (set2.Tables.Count != 0) // BJR
            {
                num94 = (set2.Tables[0].Rows.Count - 1);
            }
            i4 = 0;
            while ((i4 <= num94))
            {
                Module1.newModule.RefDes = ""; // BJR
                rep = ""; // BJR
                if (set2.Tables.Count != 0) // BJR
                {
                    Module1.newModule.RefDes = Conversions.ToString(set2.Tables[0].Rows[i4]["REFDES"]);
                    rep = Conversions.ToString(set2.Tables[0].Rows[i4]["reportnote"]);
                }
                newrep = rep.Replace("aditional ", "additional");

                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblrefdes SET reportnote ='",
          newrep,
          "' WHERE reportnote ='",
          rep,
          "'"
        }));
                i4 += 1;
            }
            set2 = data2.getData("SELECT * FROM TBLREFDES WHERE reportnote  like 'REIDENTIFY%'");
            num94 = 0; // BJR
            if (set2.Tables.Count != 0) // BJR
            {
                num94 = (set2.Tables[0].Rows.Count - 1);
            }
            i4 = 0;
            while ((i4 <= num94))
            {
                Module1.newModule.RefDes = ""; // BJR
                rep = ""; // BJR
                if (set2.Tables.Count != 0) // BJR
                {
                    Module1.newModule.RefDes = Conversions.ToString(set2.Tables[0].Rows[i4]["refplanid"]);
                    rep = Conversions.ToString(set2.Tables[0].Rows[i4]["reportnote"]);
                }


                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblrefdes SET REFWT ='' WHERE reportnote ='",
          rep,
          "'"
        }));
                i4 += 1;
            }
            set2 = data2.getData("SELECT * FROM TBLgeneral WHERE genplannumber   like '30%' and genpartsnote like '%wires to be routed%'");
            num94 = 0; // BJR
            if (set2.Tables.Count != 0) // BJR
            {
                num94 = (set2.Tables[0].Rows.Count - 1);
            }
            i4 = 0;
            while ((i4 <= num94))
            {
                Module1.newModule.RefDes = ""; // BJR
                rep = ""; // BJR
                if (set2.Tables.Count != 0) // BJR
                {
                    Module1.newModule.RefDes = Conversions.ToString(set2.Tables[0].Rows[i4]["genplid"]);
                    rep = Conversions.ToString(set2.Tables[0].Rows[i4]["genpartsnote"]);
                }
                newrep = rep.Replace("'Wires to be Routed on Aircraft ", "'LRU Reworked Wires");

                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblGeneral SET genpartsnote ='",
          newrep,
          "' WHERE genpartsnote ='",
          rep,
          "'"
        }));
                i4 += 1;
            }
            set2 = data2.getData("SELECT * FROM TBLREFDES WHERE REFPLANID ='" + start.PlanNumber + "' AND REFDES LIKE '%NEAR%'");
            int num9 = 0; // BJR
            if (set2.Tables.Count != 0) // BJR
            {
                num9 = (set2.Tables[0].Rows.Count - 1);
            }
            int i = 0;
            while ((i <= num9))
            {
                Module1.newModule.RefDes = ""; // BJR
                if (set2.Tables.Count != 0) // BJR
                {
                    Module1.newModule.RefDes = Conversions.ToString(set2.Tables[0].Rows[i]["REFDES"]);
                }
                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblrefdes SET refpreview ='",
          Guid.NewGuid().ToString(),
          "' WHERE refdes ='",
          Module1.newModule.RefDes,
          "'"
        }));
                i += 1;
            }
            string oldValue = "Rework wires";
            string newValue = "Install new wires";
            //newValue = newValue;  no reason to set a variable to itself
            DataSet set3 = new DataSet();
            set3 = data2.getData(("SELECT * FROM tblrefdes WHERE opn =5 and refwt like '%" + oldValue + "%'"));
            int num10 = 0; // BJR
            if (set3.Tables.Count != 0) // BJR
            {
                num10 = (set3.Tables[0].Rows.Count - 1);
            }
            int j = 0;
            while ((j <= num10))
            {
                string str5 = ""; // BJR
                if (set3.Tables.Count != 0) // BJR
                {
                    str5 = Conversions.ToString(set3.Tables[0].Rows[j]["refwt"]);
                }
                string str4 = str5.Replace(oldValue, newValue);
                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblRefDes SET REFWT='",
          str4,
          "' WHERE REFWT LIKE '%",
          str5,
          "'"
        }));
                j += 1;
            }
            //Wire tie ", Module1.RefWireTie, " must installed near ", Module1.LocWireTie, " see wire-ties table for aditional information."})

            start.FillProgram();
            //  cmbProgram.SelectedIndex = 1
            start.FillCountryTail();
            start.SimpleButton9.Enabled = false;


            //frmProgram.cmbCountry.SelectedIndex = 0
            frmCrunch frm1 = new frmCrunch();
            frmCards frm2 = new frmCards();
            //IsMdiContainer = true;//JMR -- BJR look at -- added in to get rid of exception error --http://forums.codeguru.com/showthread.php?469419-Mdi-parent-problem!!!!!
            frm1.MdiParent = start;;
            frm1.Show();
            frm2.MdiParent = start;
            frm2.Show();

            start.Text = "ePlanSys Oman v13.02";
            System.Windows.Forms.Application.Run(start); //BJR
            //System.Windows.Forms.Application.Run(frm1);
            //System.Windows.Forms.Application.Run(frm2);
            
        }

        private void  // ERROR: Handles clauses are not supported in C#
    NavBarControl1_Click(System.Object sender, System.EventArgs e)
        {
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            clsData data;
            //JMR -- look at --http://www.dotnetperls.com/array-vbnet --http://bytes.com/topic/visual-basic-net/answers/382069-new-oject-vs-new-object-1-a
            if ((NewLateBinding.LateGet(sender, null, "pressedlink", new object[0] { }, null, null, null) != null))
            {
                //JMR
                if (Convert.ToBoolean(this.cmbProgram.EditValue == "1111") || Convert.ToBoolean(this.cmbProgram.EditValue == "2222"))
                {
                    XtraMessageBox.Show("Please select a program first!", "ePlansys...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    //Try
                    //    Dim enumerator As IEnumerator
                    //    Try
                    //        enumerator = Application.OpenGetEnumerator
                    //        Do While enumerator.MoveNext
                    //            Dim current As Form = DirectCast(enumerator.Current, Form)
                    //            Dim name As String = current.Name
                    //            If (((name <> "frmCards") AndAlso (name <> "frmOps")) AndAlso ((name <> "frmElectrical") AndAlso (name = "frmBackShopl"))) Then
                    //            End If
                    //        Loop
                    //    Finally
                    //        If TypeOf enumerator Is IDisposable Then
                    //            TryCast(enumerator, IDisposable).Dispose()
                    //        End If
                    //    End Try
                    //Catch exception1 As Exception
                    //    ProjectData.SetProjectError(exception1)
                    //    Dim exception As Exception = exception1
                    //    ProjectData.ClearProjectError()
                    //End Try
                    object left = NewLateBinding.LateGet(NewLateBinding.LateGet(sender, null, "PressedLink", new object[0] {
            
          }, null, null, null), null, "ItemName", new object[0] {
            
          }, null, null, null);
                    //JMR
                    if (left == "ops")
                    {
                        Module1.newModule.AreaNo = 12;
                        Module1.newModule.TEAM = "OPS";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "INDUCTION";
                        goto line123;
                    }
                    if (left == "misc")
                    {
                        Module1.newModule.AreaNo = 14;
                        Module1.newModule.TEAM = "MISCELLANEOUS";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "MISCELLANEOUS";
                        goto line123;
                    }
                    if (left == "rsheetmetals")
                    {
                        Module1.newModule.AreaNo = 20;
                        Module1.newModule.TEAM = "SHEETMETAL";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "REMOVE-SHEETMETALS";
                        goto line123;
                    }
                    if (left == "rapg")
                    {
                        Module1.newModule.AreaNo = 0x16;
                        Module1.newModule.TEAM = "APG";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "REMOVE-APG";
                        goto line123;
                    }
                    if (left == "relectrical")
                    {
                        Module1.newModule.AreaNo = 0x18;
                        Module1.newModule.TEAM = "ELECTRICAL";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "REMOVE-ELECTRICAL";
                        goto line123;
                    }
                    if (left == "rmisc")
                    {
                        Module1.newModule.AreaNo = 0x1a;
                        Module1.newModule.TEAM = "MISCELLANEOUS";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "REMOVE-MISC";
                        goto line123;
                    }
                    if (left == "rwbackshop")
                    {
                        Module1.newModule.AreaNo = 30;
                        Module1.newModule.TEAM = " BACKSHOP ";
                        frmBackshopNew.newfrmBackshopNew1.Text = "REWORK-BACKSHOP";
                        goto line123;
                    }
                    if (left == "rwsheet")
                    {
                        Module1.newModule.AreaNo = 40;
                        Module1.newModule.TEAM = "SHEETMETAL";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "REWORK-SHEETMETAL";
                        goto line123;
                    }
                    if (left == "rwelectrical")
                    {
                        Module1.newModule.AreaNo = 50;
                        Module1.newModule.HarnSel = true;
                        Module1.newModule.TEAM = "ELECTRICAL";
                        frmElectrical.newfrmElectrical1.Text = "REWORK-ELECTRICAL";
                        goto line123;
                    }
                    if (left == "rwapg")
                    {
                        Module1.newModule.AreaNo = 60;
                        Module1.newModule.TEAM = "APG";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "REWORK-APG";
                        goto line123;
                    }
                    if (left == "rwmisc")
                    {
                        Module1.newModule.AreaNo = 70;
                        Module1.newModule.TEAM = "MISCELLANEOUS";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "REWORK-MISC";
                        goto line123;
                    }
                    if (left == "pmelectrical")
                    {
                        Module1.newModule.TEAM = "ELECTRICAL";
                        Module1.newModule.AreaNo = 80;
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "POST MODIFICATION";
                        goto line123;
                    }
                    if (left == "pmapg")
                    {
                        Module1.newModule.AreaNo = 0x52;
                        Module1.newModule.TEAM = "APG";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "POST MODIFICATION";
                        goto line123;
                    }
                    if (left == "pmops")
                    {
                        Module1.newModule.AreaNo = 0x54;
                        Module1.newModule.TEAM = "MISCELLANEOUS";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "POST MODIFICATION";
                        goto line123;
                    }
                    if (left == "pmpreflight")
                    {
                        Module1.newModule.AreaNo = 0x56;
                        Module1.newModule.TEAM = "MISCELLANEOUS";
                        Module1.newModule.Template = true;
                        frmOps.newfrmOps1.Text = "PREFLIGHT";
                        goto line123;
                    }
                    if (left == "Cards")
                    {                        
                        //Form f;   //JMR -- look at -- commented out because f needs to be declared inside the foreach parenthesis

                        //JMR -- look at -- replaced My.Application.OpenForms with System.Windows.Forms.Application.OpenForms
                        try
                        {
                            foreach (Form f in System.Windows.Forms.Application.OpenForms)
                            {


                                switch (f.Name)
                                {
                                    case "frmCards":
                                        f.Close();
                                        break;//JMR -- added break
                                }
                            }
                        }
                        catch (Exception ex)
                        {

                        }
                        frmCards.newfrmCards1 = new frmCards();  //BJR
                        //frmCards.newfrmCards1.Close();   //BJR
                        frmCards.newfrmCards1.MdiParent = this;
                        frmCards.newfrmCards1.Show();
                        return;
                    }
                    else if (left == "NavBarItem14")
                    {
                        //Form f;     //JMR -- look at -- commented out because f needs to be declared inside the foreach parenthesis

                        //JMR -- look at -- replaced My.Application.OpenForms with System.Windows.Forms.Application.OpenForms
                        try
                        {
                            foreach (Form f in System.Windows.Forms.Application.OpenForms)
                            {


                                switch (f.Name)
                                {
                                    case "frmCrunch":
                                        f.Close();
                                        break;//JMR -- added break

                                }
                            }
                        }
                        catch (Exception ex)
                        {

                        }
                        frmCrunch.newfrmCrunch1 = new frmCrunch();  //BJR
                        //frmCrunch.newfrmCrunch1.Close();  //BJR
                        frmCrunch.newfrmCrunch1.MdiParent = this;
                        frmCrunch.newfrmCrunch1.Show();
                        return;
                    }
                    else if (left == "oil")
                    {
                        frmCards cards = new frmCards();
                        cards.MdiParent = this;
                        cards.Show();
                        Module1.newModule.AreaNo = 0;
                        Xrsub xrSub = new Xrsub();
                        DataSet set2 = new DataSet();
                        set2 = new clsData().getData(("SELECT * FROM tblGeneral WHERE GENPROGRAM ='" + this.cmbProgram.Text + "' ORDER BY GENPLANNUMBER"));
                        xrSub.GridControl1.DataSource = set2.Tables[0];
                        //xrSub.ShowPreviewDialog(); //this was commented out in vb version
                    }
                    else if (left == "ExportDb")
                    {
                        try
                        {
                            JRO.JetEngine jro;
                            SaveFileDialog dialog = new SaveFileDialog { Filter = "mdb files (*.mdb)|*.mdb" };
                            foreach (Form frm in this.MdiChildren)
                            {
                                frm.Close();
                            }
                            if ((dialog.ShowDialog() == DialogResult.OK))
                            {
                                string fileName = dialog.FileName;
                                jro = new JRO.JetEngine();
                                System.Windows.Forms.Application.DoEvents();
                                Module1.newModule.conn.Close();
                                Module1.newModule.conn.Dispose();
                                Module1.newModule.Cn.Close();
                                Module1.newModule.Cn.Dispose();

                                jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "\\Omanmain.mdb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + " ;Jet OLEDB:Engine Type=5");
                                // My.Computer.FileSystem.RenameFile(fileName, "Omanmain.mdb")
                                XtraMessageBox.Show("Backup saved at " + fileName + ".", "Backup", MessageBoxButtons.OK);
                            }


                        }
                        catch (Exception ex)
                        {
                            Module1.newModule.repairdb = false;
                        }

                        Module1.newModule.InitConnection();
                    }
                    else if (left == "RestoreDb")
                    {
                        try
                        {
                            JRO.JetEngine jro;
                            OpenFileDialog dialog = new OpenFileDialog { Filter = "mdb files (*.mdb)|*.mdb" };

                            if ((dialog.ShowDialog() == DialogResult.OK))
                            {
                                clsData data3 = new clsData();
                                DataSet aset = new DataSet();
                                Module1.newModule.isCrunch = false;

                                string fileName = dialog.FileName;

                                Module1.newModule.newconn = fileName;
                                Module1.newModule.isCrunch = true;
                                aset = data3.getData("select *  from tblProgram where COUNTRY = 'Oman'");
                                try
                                {
                                    if (aset.Tables[0].Rows.Count == 1)
                                    {
                                    }
                                    else
                                    {
                                        XtraMessageBox.Show("Wrong file selected " + fileName + ".", "restore", MessageBoxButtons.OK);
                                        Module1.newModule.isCrunch = false;
                                        return;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    XtraMessageBox.Show("Wrong file selected " + fileName + ".", "restore", MessageBoxButtons.OK);
                                    return;
                                }
                                Module1.newModule.isCrunch = false;

                                jro = new JRO.JetEngine();
                                System.Windows.Forms.Application.DoEvents();
                                Module1.newModule.conn.Close();
                                Module1.newModule.conn.Dispose();

                                DialogResult fansd;
                                foreach (Form frm in this.MdiChildren)
                                {
                                    frm.Close();
                                }
                                fansd = XtraMessageBox.Show("This action will delete the old db, are you sure?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                                if (fansd == DialogResult.Yes)
                                {
                                    foreach (Form frm in this.MdiChildren)
                                    {
                                        frm.Close();
                                    }
                                    if (fileName.EndsWith("xml"))
                                    {
                                        //My.Computer.FileSystem.RenameFile(fileName, "Omanmain.mdb")
                                    }
                                    //My.Computer.FileSystem.DeleteFile(Application.StartupPath + "\\Omanmain.mdb");
                                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Omanmain.mdb");//JMR -- look at -- replaced line above with this line
                                    jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "\\Omanmain.mdb" + " ;Jet OLEDB:Engine Type=5");
                                    // My.Computer.FileSystem.RenameFile(fileName, "Omanmain.mdb")
                                    XtraMessageBox.Show("Backup restored from " + fileName + ".", "restore", MessageBoxButtons.OK);
                                }

                            }


                        }
                        catch (Exception ex)
                        {
                            Module1.newModule.repairdb = false;
                            XtraMessageBox.Show("Wrong file selected.", "restore", MessageBoxButtons.OK);
                            return;
                        }

                        Module1.newModule.InitConnection();

                    }
                    else
                    {
                        if (left == "mprsdata")
                        {
                            frmWait wait = new frmWait();
                            OpenFileDialog dialog = new OpenFileDialog();
                            clsData data4 = new clsData();
                            Control.CheckForIllegalCrossThreadCalls = (false);
                            Module1.newModule.excist = true;
                            this.dsCrunch.Clear();
                            Module1.newModule.Createadapter(this.dsCrunch, "CBE", "Q", ref this.daCBE);
                            Module1.newModule.Createadapter(this.dsCrunch, "PTP", "Q", ref this.daPTP);
                            Module1.newModule.Createadapter(this.dsCrunch, "MPRS", "Q", ref this.daMPRS);
                            System.Windows.Forms.Application.DoEvents();
                            dialog.InitialDirectory = "c:\\";
                            dialog.Filter = "Microsoft Acess files (*.MDB)|*.MDB|All files (*.*)|*.*";
                            if ((dialog.ShowDialog() == DialogResult.OK))
                            {
                                Module1.newModule.NAMF = dialog.FileName;
                            }
                            else
                            {
                                return;
                            }
                            MprsUpdate();
                            //dialog.InitialDirectory = "c:\"
                            //dialog.Filter = "Microsoft Acess files (*.MDB)|*.MDB|All files (*.*)|*.*"
                            //If (dialog.ShowDialog = DialogResult.OK) Then
                            //    Module1.NAMF = dialog.FileName
                            //    Module1.Template = True


                            //Me.updatethread = New Thread(AddressOf MprsUpdate)
                            //Me.updatethread.IsBackground = True
                            //Me.updatethread.Name = "UpdateThread"
                            //Me.updatethread.Start()
                            //'    Module1.ISRUNN = True
                            //Do Until ISRUNN = False

                            //Loop
                            //End If
                            return;
                        }
                        if (left == "Clear")
                        {
                            // Module1.Cleardb()
                        }
                        else if (left == "UpdateDataBase")
                        {
                            this.dsExport.Clear();
                            this.PlanNumber = Guid.NewGuid().ToString();
                            Module1.newModule.Createadapter(this.dsExport, "pdfWires", ("TERM ='" + this.PlanNumber + "'"), ref this.daTransferRevision);
                            Module1.newModule.Createadapter(this.dsExport, "tblBackShopWires", ("bacPlId ='" + this.PlanNumber + "'"), ref this.daTransferBackShop);
                            Module1.newModule.Createadapter(this.dsExport, "tblCont", ("bacPlId ='" + this.PlanNumber + "'"), ref this.daTransferCont);
                            Module1.newModule.Createadapter(this.dsExport, "tblDrawings", ("DwgPlId ='" + this.PlanNumber + "'"), ref this.daTransferDrawings);
                            Module1.newModule.Createadapter(this.dsExport, "tblTools", ("tlPlid ='" + this.PlanNumber + "'"), ref this.daTransferTools);
                            Module1.newModule.Createadapter(this.dsExport, "tblEffectivities", ("efPlId = '" + this.PlanNumber + "'"), ref this.daTransferEffectivities);
                            Module1.newModule.Createadapter(this.dsExport, "tblGeneral", ("genPlId = '" + this.PlanNumber + "'"), ref this.daTransferGeneral);
                            Module1.newModule.Createadapter(this.dsExport, "tblmisc", ("MISCPLANID = '" + this.PlanNumber + "'"), ref this.daTransferMisc);
                            Module1.newModule.Createadapter(this.dsExport, "tblNotes", ("plNotesId = '" + this.PlanNumber + "'"), ref this.daTransferNotes);
                            Module1.newModule.Createadapter(this.dsExport, "tblPlano", ("PlannoId = '" + this.PlanNumber + "'"), ref this.daTransferPlano);
                            Module1.newModule.Createadapter(this.dsExport, "tblRefDes", ("RefPlanId = '" + this.PlanNumber + "'"), ref this.daTransferRefDes);
                            Module1.newModule.Createadapter(this.dsExport, "tblRefDesComp", ("REFCOMPPLID ='" + this.PlanNumber + "'"), ref this.daTransferRefDesComp);
                            Module1.newModule.Createadapter(this.dsExport, "tblRoute", ("rPlId ='" + this.PlanNumber + "'"), ref this.daTransferRoute);
                            Module1.newModule.Createadapter(this.dsExport, "tblSelHarness", ("hrnSelPlId ='" + this.PlanNumber + "'"), ref this.daTransferSelHarness);
                            Module1.newModule.Createadapter(this.dsExport, "tblTemplate", ("tmpPlid ='" + this.PlanNumber + "'"), ref this.daTransferTemplate);
                            Module1.newModule.Createadapter(this.dsExport, "tblAssembly", ("prtPlId = '" + this.PlanNumber + "'"), ref this.daTransferAssembly);
                            Module1.newModule.Createadapter(this.dsExport, "tblWires", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWires);
                            Module1.newModule.Createadapter(this.dsExport, "tblWiresAdd", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresAdd);
                            Module1.newModule.Createadapter(this.dsExport, "tblWiresRemove", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresRemove);
                            Module1.newModule.Createadapter(this.dsExport, "tblWiresRevise", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresRevise);
                            Module1.newModule.Createadapter(this.dsExport, "tblMisc", (" MISCPLANID ='" + this.PlanNumber + "'"), ref this.daTransferMisc);
                            Module1.newModule.Createadapter(this.dsExport, "tblWiresBackshell", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresBackshell);
                            this.dsExport.WriteXmlSchema((System.Windows.Forms.Application.StartupPath + "\\test.XML"));
                            OpenFileDialog dialog2 = new OpenFileDialog();
                            DataSet set5 = new DataSet();
                            DataSet set6 = new DataSet();
                            int num5 = 0;
                            dialog2.Filter = "xml files (*.xml)|*.xml";
                            if ((dialog2.ShowDialog() == DialogResult.OK))
                            {
                                string str4;
                                string fileName = dialog2.FileName;
                                if (fileName.EndsWith("fixGD.xml"))
                                {
                                    set5.ReadXmlSchema((System.Windows.Forms.Application.StartupPath + "\\test.XML"));
                                    set5.ReadXml(fileName);
                                    DataSet set11 = new DataSet();
                                    clsData data7 = new clsData();
                                    this.dsExport = set5.Copy();
                                    this.daTransferRefDes.Update(this.dsExport, "tblRefDes");
                                    set11 = data7.getData("SELECT DISTINCT REFDES,REFDESID,REFPLANID FROM TBLREFDES WHERE Refdes like '%GD%' and baseref like '%GD%'");
                                    int num33 = (set11.Tables[0].Rows.Count - 1);
                                    int i = 0;
                                    while ((i <= num33))
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set11.Tables[0].Rows[i]["REFDESID"]);
                                        Module1.newModule.RefDes = Conversions.ToString(set11.Tables[0].Rows[i]["REFDES"]);
                                        str4 = Conversions.ToString(set11.Tables[0].Rows[i]["REFPLANID"]);
                                        data7.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data7.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESADD SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data7.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESREMOVE SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data7.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESREVISE SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data7.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESBACKSHELL SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data7.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE tblMisc SET miscrefdesid = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE MISCREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND MISCPLANID ='",
                      str4,
                      "'"
                    }));
                                        i += 1;
                                    }
                                }
                                else
                                {
                                    set5.ReadXmlSchema((System.Windows.Forms.Application.StartupPath + "\\test.XML"));
                                    set5.ReadXml(fileName);
                                    this.dsExport = set5.Copy();
                                    str4 = "";
                                    if (this.dsExport.Tables["tblGeneral"].Rows.Count != 0)
                                    {
                                        str4 = Conversions.ToString(this.dsExport.Tables["tblGeneral"].Rows[0]["genPlId"]);
                                    }
                                    DialogResult result2 = XtraMessageBox.Show("Create new card?", "Confirm action.", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                    if ((result2 == DialogResult.Yes))
                                    {
                                        DataSet set10 = new DataSet();
                                        Module1.newModule.strarea = Conversions.ToString(this.dsExport.Tables["tblGeneral"].Rows[0]["genPlanNumber"]);
                                        Module1.newModule.strarea = Module1.newModule.strarea.Substring(0, 2);
                                        num5 = Conversions.ToInteger(Module1.newModule.strarea);
                                        DataSet set110 = new DataSet();
                                        clsData drc2 = new clsData();
                                        set110 = drc2.getData(("SELECT MAX (genPlannumber) AS maxid1 FROM TBLGENERAL WHERE genPlannumber LIKE '" + Module1.newModule.strarea + "%'"));
                                        if ((object.ReferenceEquals(set110.Tables[0].Rows[0]["maxid1"], DBNull.Value)))
                                        {
                                            Module1.newModule.strPlannumber = 1;
                                        }
                                        else
                                        {
                                            Module1.newModule.strPlannumber = Conversions.ToInteger(Conversions.ToString(set110.Tables[0].Rows[0]["maxid1"]).Substring(3, 3));
                                            Module1.newModule.strPlannumber += 1;
                                        }
                                        DataRow row2;
                                        DataRow[] source = this.dsExport.Tables[0].Select(("WIRESPLID='" + str4 + "'"));
                                        int num34 = (source.Count() - 1);//JMR
                                        int k = 0;
                                        while ((k <= num34))
                                        {
                                            row2 = source[k];//JMR
                                            row2[9] = this.PlanNumber;
                                            k += 1;
                                        }
                                        source = this.dsExport.Tables[1].Select(("REFCOMpPLID='" + str4 + "'"));
                                        int num35 = (source.Count() - 1);//JMR
                                        int m = 0;
                                        while ((m <= num35))
                                        {
                                            row2 = source[m];
                                            row2[0] = this.PlanNumber;
                                            m += 1;
                                        }
                                        source = this.dsExport.Tables[2].Select(("MISCPLANID='" + str4 + "'"));
                                        int num36 = (source.Count() - 1);
                                        int n = 0;
                                        while ((n <= num36))
                                        {
                                            row2 = source[n];
                                            row2[3] = this.PlanNumber;
                                            n += 1;
                                        }
                                        source = this.dsExport.Tables[3].Select(("RPLID='" + str4 + "'"));
                                        int num37 = (source.Count() - 1);
                                        int num11 = 0;
                                        while ((num11 <= num37))
                                        {
                                            row2 = source[num11];
                                            row2[0] = this.PlanNumber;
                                            num11 += 1;
                                        }
                                        source = this.dsExport.Tables[4].Select(("REFPLANID='" + str4 + "'"));
                                        int num38 = (source.Count() - 1);
                                        int num12 = 0;
                                        while ((num12 <= num38))
                                        {
                                            row2 = source[num12];
                                            row2[5] = this.PlanNumber;
                                            num12 += 1;
                                        }
                                        source = this.dsExport.Tables[5].Select("genProgram like '%%'");
                                        int num39 = (source.Count() - 1);
                                        int num13 = 0;
                                        while ((num13 <= num39))
                                        {
                                            row2 = source[num13];
                                            row2[2] = "Oman";
                                            this.IsOther = true;
                                            num13 += 1;
                                        }
                                        source = this.dsExport.Tables[5].Select(("GENPLID='" + str4 + "'"));
                                        int num40 = (source.Count() - 1);
                                        int num14 = 0;
                                        while ((num14 <= num40))
                                        {
                                            row2 = source[num14];
                                            row2[0] = this.PlanNumber;
                                            num14 += 1;
                                        }
                                        source = this.dsExport.Tables[6].Select(("DWGPLID='" + str4 + "'"));
                                        int num41 = (source.Count() - 1);
                                        int num15 = 0;
                                        while ((num15 <= num41))
                                        {
                                            row2 = source[num15];
                                            row2[0] = this.PlanNumber;
                                            num15 += 1;
                                        }
                                        source = this.dsExport.Tables[7].Select(("TLPLID='" + str4 + "'"));
                                        int num42 = (source.Count() - 1);
                                        int num16 = 0;
                                        while ((num16 <= num42))
                                        {
                                            row2 = source[num16];
                                            row2[6] = this.PlanNumber;
                                            num16 += 1;
                                        }
                                        source = this.dsExport.Tables[8].Select(("TMPpLID='" + str4 + "'"));
                                        int num43 = (source.Count() - 1);
                                        int num17 = 0;
                                        while ((num17 <= num43))
                                        {
                                            row2 = source[num17];
                                            row2[0] = this.PlanNumber;
                                            num17 += 1;
                                        }
                                        source = this.dsExport.Tables[9].Select(("BACPLID='" + str4 + "'"));
                                        int num44 = (source.Count() - 1);
                                        int num18 = 0;
                                        while ((num18 <= num44))
                                        {
                                            row2 = source[num18];
                                            row2[0] = this.PlanNumber;
                                            num18 += 1;
                                        }
                                        source = this.dsExport.Tables[10].Select(("plNotesId='" + str4 + "'"));
                                        int num45 = (source.Count() - 1);
                                        int num19 = 0;
                                        while ((num19 <= num45))
                                        {
                                            row2 = source[num19];
                                            row2[0] = this.PlanNumber;
                                            num19 += 1;
                                        }
                                        source = this.dsExport.Tables[11].Select(("bacPLID='" + str4 + "'"));
                                        int num46 = (source.Count() - 1);
                                        int num20 = 0;
                                        while ((num20 <= num46))
                                        {
                                            row2 = source[num20];
                                            row2[0] = this.PlanNumber;
                                            num20 += 1;
                                        }
                                        source = this.dsExport.Tables[12].Select(("efPLID='" + str4 + "'"));
                                        int num47 = (source.Count() - 1);
                                        int num21 = 0;
                                        while ((num21 <= num47))
                                        {
                                            row2 = source[num21];
                                            row2[0] = this.PlanNumber;
                                            num21 += 1;
                                        }
                                        source = this.dsExport.Tables[13].Select(("plannoid='" + str4 + "'"));
                                        int num48 = (source.Count() - 1);
                                        int num22 = 0;
                                        while ((num22 <= num48))
                                        {
                                            row2 = source[num22];
                                            row2[0] = this.PlanNumber;
                                            num22 += 1;
                                        }
                                        source = this.dsExport.Tables[14].Select(("hrnselPLID='" + str4 + "'"));
                                        int num49 = (source.Count() - 1);
                                        int num23 = 0;
                                        while ((num23 <= num49))
                                        {
                                            row2 = source[num23];
                                            row2[0] = this.PlanNumber;
                                            num23 += 1;
                                        }
                                        source = this.dsExport.Tables[15].Select(("prtPLID='" + str4 + "'"));
                                        int num50 = (source.Count() - 1);
                                        int num24 = 0;
                                        while ((num24 <= num50))
                                        {
                                            row2 = source[num24];
                                            row2[0] = this.PlanNumber;
                                            num24 += 1;
                                        }
                                        source = this.dsExport.Tables[0x10].Select(("WIRESPLID='" + str4 + "'"));
                                        int num51 = (source.Count() - 1);
                                        int num25 = 0;
                                        while ((num25 <= num51))
                                        {
                                            row2 = source[num25];
                                            row2[9] = this.PlanNumber;
                                            num25 += 1;
                                        }
                                        source = this.dsExport.Tables[0x11].Select(("WIRESPLID='" + str4 + "'"));
                                        int num52 = (source.Count() - 1);
                                        int num26 = 0;
                                        while ((num26 <= num52))
                                        {
                                            row2 = source[num26];
                                            row2[9] = this.PlanNumber;
                                            num26 += 1;
                                        }
                                        source = this.dsExport.Tables[0x12].Select(("WIRESPLID='" + str4 + "'"));
                                        int num53 = (source.Count() - 1);
                                        int num27 = 0;
                                        while ((num27 <= num53))
                                        {
                                            row2 = source[num27];
                                            row2[9] = this.PlanNumber;
                                            num27 += 1;
                                        }
                                        source = this.dsExport.Tables[0x13].Select(("WIRESPLID='" + str4 + "'"));
                                        int num54 = (source.Count() - 1);
                                        int num28 = 0;
                                        while ((num28 <= num54))
                                        {
                                            row2 = source[num28];
                                            row2[9] = this.PlanNumber;
                                            num28 += 1;
                                        }
                                        source = this.dsExport.Tables[0x15].Select(("WIRESPLID='" + str4 + "'"));
                                        int num55 = (source.Count() - 1);
                                        int num29 = 0;
                                        while ((num29 <= num55))
                                        {
                                            row2 = source[num29];
                                            row2[9] = this.PlanNumber;
                                            num29 += 1;
                                        }
                                        try
                                        {
                                            source = this.dsExport.Tables[20].Select(("TERM='" + str4 + "'"));
                                            int num56 = (source.Count() - 1);
                                            int num30 = 0;
                                            while ((num30 <= num56))
                                            {
                                                row2 = source[num30];
                                                row2[4] = this.PlanNumber;
                                                num30 += 1;
                                            }
                                        }
                                        catch (Exception exception5)
                                        {
                                            ProjectData.SetProjectError(exception5);
                                            Exception exception2 = exception5;
                                            ProjectData.ClearProjectError();
                                        }
                                        try
                                        {
                                            source = this.dsExport.Tables[0x15].Select(("TERM='" + str4 + "'"));
                                            int num57 = (source.Count() - 1);
                                            int num31 = 0;
                                            while ((num31 <= num57))
                                            {
                                                row2 = source[num31];
                                                row2[4] = this.PlanNumber;
                                                num31 += 1;
                                            }
                                        }
                                        catch (Exception exception6)
                                        {
                                            ProjectData.SetProjectError(exception6);
                                            Exception exception3 = exception6;
                                            ProjectData.ClearProjectError();
                                        }
                                    }
                                    try
                                    {
                                        this.daTransferGeneral.Update(this.dsExport, "tblGeneral");
                                    }
                                    catch (Exception exception7)
                                    {
                                        ProjectData.SetProjectError(exception7);
                                        Exception exception4 = exception7;
                                        ProjectData.ClearProjectError();
                                    }
                                    str4 = Conversions.ToString(this.dsExport.Tables["tblGeneral"].Rows[0]["genPlId"]);
                                    clsData drc4 = new clsData();
                                    DataSet set7 = drc4.getData(("select * from tblplano where plannoid ='" + str4 + "'"));
                                    int strPlannumber = Module1.newModule.strPlannumber;
                                    Module1.newModule.STRPLANO = (Module1.newModule.strarea + "-" + Conversions.ToString(Module1.newModule.strPlannumber).PadLeft(3, '0'));
                                    if (!this.IsOther)
                                    {
                                        this.daTransferDrawings.Update(this.dsExport, "tblDrawings");
                                        this.daTransferEffectivities.Update(this.dsExport, "tblEffectivities");
                                        this.daTransferAssembly.Update(this.dsExport, "tblAssembly");
                                    }
                                    else
                                    {
                                        this.IsOther = false;
                                        try
                                        {
                                            this.daTransferDrawings.Update(this.dsExport, "tblDrawings");
                                        }
                                        catch (Exception ex)
                                        {

                                        }
                                        try
                                        {
                                            this.daTransferEffectivities.Update(this.dsExport, "tblEffectivities");
                                        }
                                        catch (Exception ex)
                                        {

                                        }
                                        try
                                        {
                                            this.daTransferAssembly.Update(this.dsExport, "tblAssembly");
                                        }
                                        catch (Exception ex)
                                        {

                                        }

                                    }
                                    this.daTransferBackShop.Update(this.dsExport, "tblBackShopWires");
                                    this.daTransferCont.Update(this.dsExport, "tblCont");
                                    this.daTransferRevision.Update(this.dsExport, "pdfWires");
                                    this.daTransferGeneral.Update(this.dsExport, "tblGeneral");
                                    this.daTransferDrawings.Update(this.dsExport, "tblDrawings");
                                    this.daTransferMisc.Update(this.dsExport, "tblMisc");
                                    this.daTransferNotes.Update(this.dsExport, "tblNotes");
                                    this.daTransferRefDes.Update(this.dsExport, "tblRefDes");
                                    this.daTransferRefDesComp.Update(this.dsExport, "tblRefDesComp");
                                    this.daTransferRoute.Update(this.dsExport, "tblRoute");
                                    this.daTransferSelHarness.Update(this.dsExport, "tblSelHarness");
                                    this.daTransferTemplate.Update(this.dsExport, "tblTemplate");
                                    this.daTransferTools.Update(this.dsExport, "tblTools");
                                    this.daTransferWires.Update(this.dsExport, "tblWires");
                                    this.daTransferWiresAdd.Update(this.dsExport, "tblWiresAdd");
                                    this.daTransferWiresBackshell.Update(this.dsExport, "tblWiresBackShell");
                                    this.daTransferWiresRemove.Update(this.dsExport, "tblWiresRemove");
                                    this.daTransferWiresRevise.Update(this.dsExport, "tblWiresRevise");
                                    this.daTransferPlano.Update(this.dsExport, "tblPlano");
                                    this.daTransferEffectivities.Update(dsExport, "tblEffectivities");
                                    drc4.ExecuteSQL(string.Concat(new string[] {
                    "update tblPlano set  AreaNo =",
                    Conversions.ToString(num5),
                    " ,Description = ",
                    Conversions.ToString(strPlannumber),
                    " where PlannoId = '",
                    str4,
                    "'"
                  }));
                                    drc4.ExecuteSQL(string.Concat(new string[] {
                    "update tblGeneral set  genPlanNumber ='",
                    Module1.newModule.STRPLANO,
                    " 'where genPlId = '",
                    str4,
                    "'"
                  }));
                                    DataSet set9 = new DataSet();
                                    clsData data6 = new clsData();
                                    set9 = data6.getData(("SELECT DISTINCT REFDES,REFDESID FROM TBLREFDES WHERE REFPLANID = '" + str4 + "'"));
                                    int num58 = (set9.Tables[0].Rows.Count - 1);
                                    int j = 0;
                                    while ((j <= num58))
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set9.Tables[0].Rows[j]["REFDESID"]);
                                        Module1.newModule.RefDes = Conversions.ToString(set9.Tables[0].Rows[j]["REFDES"]);
                                        data6.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data6.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESADD SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data6.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESREMOVE SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data6.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESREVISE SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data6.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESBACKSHELL SET WREFDESID = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE SREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND WIRESPLID ='",
                      str4,
                      "'"
                    }));
                                        data6.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE tblMisc SET miscrefdesid = '",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      "' WHERE MISCREFDES = '",
                      Module1.newModule.RefDes,
                      "' AND MISCPLANID ='",
                      str4,
                      "'"
                    }));
                                        j += 1;
                                    }
                                    clsData data5 = new clsData();
                                    DataSet set8 = new DataSet();
                                    XtraMessageBox.Show(("Import completed." + thirteen + ten + "CARD NO : " + Module1.newModule.STRPLANO));

                                    //Form f;    //JMR -- look at -- commented out for declaration inside foreach parenthesis

                                    try
                                    {
                                        foreach (Form f in System.Windows.Forms.Application.OpenForms)
                                        {



                                            switch (f.Name)
                                            {
                                                case "frmCards":
                                                    f.Close();
                                                    break;//JMR -- added break

                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {

                                    }

                                    frmCards.newfrmCards1.Close();
                                    frmCards.newfrmCards1.MdiParent = this;
                                    frmCards.newfrmCards1.Show();
                                }
                            }
                        }
                    }
                }
            }
            return;
        line123:

            clsData dc = new clsData();
            DataSet ds = new DataSet();
            string sql;
            frmPLANNUMBER frmno = new frmPLANNUMBER();

            //Set Number of planning card
            sql = (" select max (description) AS maxid1 from tblplano where AreaNo =" + Module1.newModule.AreaNo);
            ds = dc.getData(sql);
            if (object.ReferenceEquals(ds.Tables[0].Rows[0]["maxid1"], DBNull.Value))
            {
                Module1.newModule.strPlannumber = 1;
            }
            else
            {
                Module1.newModule.strPlannumber = Conversions.ToInteger(ds.Tables[0].Rows[0]["maxid1"]) + 1;
            }

            //sql = (" select max (plannoid)AS maxid from tblplano")
            //ds = dc.getData(sql, ni)
            //If ds.Tables(0).Rows(0)("maxid") Is DBNull.Value Then
            //    PlanNumber = 1
            //Else
            //    PlanNumber = ds.Tables(0).Rows(0)("maxid") + 1
            //End If
            Module1.newModule.plnumber = Guid.NewGuid().ToString().Trim();
            PlanNumber = Module1.newModule.plnumber;




            //check if ecn is selected
            clsData dcdrw = new clsData();
            if (Module1.newModule.startinG == true)
            {

                //dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru) VALUES ( '" & PlanNumber & "' & ",'" & DrwNo & "-" & strEcn & "','ECN " & "-" & TITLE & "','" & DRWREV & "','" & TypeVer & "'," & FRMO & "," & THRU & ")")
                //dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru) VALUES ( '" & PlanNumber & "' & ",'" & DrwNo & "','B/P " & "-" & TITLE & "','" & DRWREV & "','" & TypeVer & "'," & FRMO & "," & THRU & ")")
                dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '" + Module1.newModule.plnumber + "','" + Module1.newModule.DrwNo + "-" + Module1.newModule.strEcn + "','ECN','" + Module1.newModule.DRWREV + "','" + Module1.newModule.tv + "'," + Module1.newModule.fr + "," + Module1.newModule.trhu + ",'" + Module1.newModule.strEcn + "','Started Pl/c " + Module1.newModule.STRPLANO + "')");
                dc.ExecuteSQL("INSERT INTO tblEffectivities(efPlid,efTypeVer,efFrom,efThru) VALUES ( '" + PlanNumber + "','" + Module1.newModule.tv + "','" + Module1.newModule.fr + "','" + Conversions.ToInteger(Module1.newModule.strTHRU) + "')");
                // dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '" & PlanNumber & "','" & DrwNo & "-" & strEcn & "','ECN','" & DRWREV & "','" & typever & "'," & FRMO & "," & thru & ",'" & strEcn & "','Started Pl/c " & STRPLANO & "')")
                if (Module1.newModule.DrwNo.Contains("H16DW")) // ERROR: Unknown binary operator Like //JMR -- fixed
                {

                }
                else
                {
                    dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '" + Module1.newModule.plnumber + "','" + Module1.newModule.DrwNo + "-" + Module1.newModule.strEcn + "','ECN','" + Module1.newModule.DRWREV + "','" + Module1.newModule.tv + "'," + Module1.newModule.fr + "," + Module1.newModule.trhu + ",'" + Module1.newModule.strEcn + "','Started Pl/c " + Module1.newModule.STRPLANO + "')");

                    dcdrw.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '" + Module1.newModule.plnumber + "','" + Module1.newModule.DrwNo + "','B/P','" + Module1.newModule.DRWREV + "','" + Module1.newModule.tv + "'," + Module1.newModule.fr + "," + Module1.newModule.trhu + ",'" + Module1.newModule.strEcn + "','Started Pl/c " + Module1.newModule.STRPLANO + "')");
                }

                //dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES) VALUES ( '" & PlanNumber & "' & ",'" & plEcn & "','ECN " & TITLE & "','" & DRWREV & "')")

            }
            else
            {
                txtDrawing.Text = "";
                if (Module1.newModule.Template == false)
                {
                    XtraMessageBox.Show("YOU MUST DOUBLE CLICK ON A ECN TO START");
                    return;
                }
            }

            if (Module1.newModule.Template == false)
            {
                frmno.plano.Text = Conversions.ToString(Module1.newModule.strPlannumber);
                frmno.plano.Text = frmno.plano.Text.PadLeft(3, '0');//JMR -- look at -- changed "0" to '0'

                //If strPlannumber > 99 Then
                //    frmno.plano.Text = CStr(strPlannumber)
                //Else
                //    If strPlannumber > 9 Then
                //        frmno.plano.Text = ("0" & strPlannumber)
                //    Else
                //        frmno.plano.Text = ("00" & strPlannumber)
                //    End If

                //End If
                Module1.newModule.planoAgain = frmno.plano.Text;
                frmno.txtArea.Text = Conversions.ToString(Module1.newModule.AreaNo);
                Module1.newModule.STRPLANO = Conversions.ToString(Module1.newModule.AreaNo) + "-" + Module1.newModule.planoAgain;
                //  dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES) VALUES ( '" & PlanNumber & "' & ",'" & strEcn & "','ECN " & TITLE & "','" & DRWREV & "')")

                Module1.newModule.startinG = false;
                using (frmSel FRM = new frmSel())
                {
                    FRM.lblStrECN.Visible = true;
                    FRM.txtStartEcn.Visible = true;
                    FRM.txtStartEcn.Text = Module1.newModule.DrwNo + " - " + txtDrawing.Text;
                    FRM.lblEcn.Text = Module1.newModule.strEcn;
                    FRM.ShowDialog();
                }

                frmno.ShowDialog();
                System.Windows.Forms.Application.DoEvents();
                frmWait.newfrmWait1.MdiParent = this;
                frmWait.newfrmWait1.Show();
                if (Module1.newModule.FormCloseex == true)
                {
                    return;
                }
                Module1.newModule.Template = false;
                if (Module1.newModule.AreaNo == 50)
                {
                    if (Module1.newModule.HarnSel == true)
                    {
                        Module1.newModule.HarnSel = false;
                        frmHarness frmHarnSel = new frmHarness();
                        frmHarnSel.ShowDialog();
                    }
                    if (Module1.newModule.FormCloseex == true)
                    {

                    }
                    else
                    {
                        System.Windows.Forms.Application.DoEvents();
                        frmWait.newfrmWait1.MdiParent = this;
                        frmWait.newfrmWait1.Show();
                        frmElectrical Frme = new frmElectrical();


                        Frme.MdiParent = this;
                        Module1.newModule.excist = false;
                        Frme.Text = Module1.newModule.STRPLANO;
                        Frme.Show();
                        frmWait.newfrmWait1.Close();
                    }

                }
                else
                {
                    frmBackshopNew frm = new frmBackshopNew();
                    Module1.newModule.backshop = true;
                    frm.MdiParent = this;
                    frm.Text = Module1.newModule.STRPLANO;
                    frm.Show();

                }


            }
            else
            {
                //If strPlannumber > 99 Then
                //    frmno.plano.Text = CStr(strPlannumber)
                //Else
                //    If strPlannumber > 9 Then
                //        frmno.plano.Text = ("0" & strPlannumber)
                //    Else
                //        frmno.plano.Text = ("00" & strPlannumber)
                //    End If

                //End If
                frmno.plano.Text = Conversions.ToString(Module1.newModule.strPlannumber);
                frmno.plano.Text = frmno.plano.Text.PadLeft(3, '0');//JMR -- look at -- changed "0" to '0'
                frmno.txtArea.Text = Conversions.ToString(Module1.newModule.AreaNo);
                DialogResult ans;
                bool selectedstaht = false;//JMR -- look at -- set to false
                if (Module1.newModule.startinG == false)
                {

                    ans = XtraMessageBox.Show("Associate ECN with this Planning Card ?", "Creating", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    Module1.newModule.OpsEcn = true;
                }
                else
                {
                    ans = XtraMessageBox.Show("Ecn -'" + Module1.newModule.strEcn + "'- already selected associate more ECN(s) with this Planning Card ?", "Creating", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    selectedstaht = true;

                    Module1.newModule.startinG = false;
                }
                if (ans == DialogResult.Yes)
                {
                    frmno.txtArea.Text = Conversions.ToString(Module1.newModule.AreaNo);
                    Module1.newModule.STRPLANO = Conversions.ToString(Module1.newModule.AreaNo) + "-" + frmno.plano.Text;
                    Module1.newModule.startinG = false;
                    using (frmSel frmS = new frmSel())
                    {
                        frmS.lblStrECN.Visible = true;
                        frmS.txtStartEcn.Visible = true;
                        frmS.txtStartEcn.Text = Module1.newModule.DrwNo + "-" + Module1.newModule.strEcn;
                        frmS.lblEcn.Text = Module1.newModule.strEcn;
                        frmS.ShowDialog();
                    }
                }
                else
                {
                    if (selectedstaht == true)
                    {

                    }
                    else
                    {
                        Module1.newModule.TITLE = null;
                        txtDrawing.Text = "";
                        Module1.newModule.stath = "Nothing";
                    }

                    frmno.txtArea.Text = Conversions.ToString(Module1.newModule.AreaNo);


                    Module1.newModule.STRPLANO = Conversions.ToString(Module1.newModule.AreaNo) + "-" + frmno.plano.Text;
                    //If ecnComment.Contains(STRPLANO) Then

                    //Else

                    //    ecnComment += ","
                    //    startinG = False
                    //    ecnComment += " Started Pl/c " & STRPLANO
                    dc.ExecuteSQL("UPDATE tblEcn set  comment ='" + Module1.newModule.ecnComment + "Started Pl/c " + Module1.newModule.STRPLANO + " 'where DRAWING = '" + Module1.newModule.DrwNo + "' and ECN = '" + Module1.newModule.stath + "'  AND DASH ='" + Module1.newModule.DRWREV + "' AND TYPEVER ='" + Module1.newModule.tv + "' AND FR0M ='" + Module1.newModule.strFrmo + "' AND THRU='" + Module1.newModule.strTHRU + "'");

                    //End If
                    Module1.newModule.startinG = false;
                }

                //    frmno.plano.Text = PlanNumber
                frmno.ShowDialog();
                Module1.newModule.Template = false;
                if (Module1.newModule.FormCloseex == true)
                {

                }
                else
                {
                    dc.ExecuteSQL("INSERT INTO TBLPLANO(PlannoId,AREANO,DESCRIPTION,revchng,typeVer,Program,plFrom,plThru) VALUES ('" + PlanNumber + "'," + Module1.newModule.AreaNo + "," + Module1.newModule.strPlannumber + ",'" + Module1.newModule.EFFECTIVITIES + "','','" + cmbProgram.Text + "','','')");
                    if (String.IsNullOrEmpty(Module1.newModule.tv))
                    {
                        Module1.newModule.tv = "999";
                        Module1.newModule.fr = 1;
                        Module1.newModule.strTHRU = "999";
                    }
                    dc.ExecuteSQL("INSERT INTO tblEffectivities(efPlid,efTypeVer,efFrom,efThru) VALUES ( '" + PlanNumber + "','" + Module1.newModule.tv + "','" + Module1.newModule.fr + "','" + Conversions.ToInteger(Module1.newModule.strTHRU) + "')");


                    frmOps Frm = new frmOps();
                    Frm.MdiParent = this;
                    Frm.Show();
                }

            }
            // End If
            //frmCards.MdiParent = Me
            //frmCards.Show()

        }
        private void PrintCards()
        {
            xrM1ain eos20 = new xrM1ain();
            xrback eos30 = new xrback();
            xrM1ain eos40 = new xrM1ain();
            xrMain eos50 = new xrMain();
            xrM1ain eos100 = new xrM1ain();

            DataSet aset = new DataSet();
            clsData data = new clsData();
            System.Drawing.Rectangle workingArea = SystemInformation.WorkingArea;
            //Module1.x = ((workingArea.Left + workingArea.Width) - Me.Width)
            //Module1.y = ((workingArea.Top + workingArea.Height) - Me.Height)
            Control.CheckForIllegalCrossThreadCalls = false;
            Module1.newModule.printall = true;
            Module1.newModule.excist = true;
            frmWait.newfrmWait1.ControlBox = true;
            frmWait.newfrmWait1.FormBorderStyle = FormBorderStyle.FixedDialog;
            frmWait.newfrmWait1.TransparencyKey = Color.Aqua;
            frmWait.newfrmWait1.StartPosition = FormStartPosition.CenterScreen;
            frmWait.newfrmWait1.Width = 400;
            frmWait.newfrmWait1.Height = 120;
            frmWait.newfrmWait1.UseWaitCursor = false;
            // frmWait.SimpleButton1.Visible = True
            frmWait.newfrmWait1.ShowInTaskbar = true;
            frmWait.newfrmWait1.Show();
            aset = data.getData(string.Concat(new string[] {
        "SELECT * FROM tblGeneral WHERE genPlId in([select] efPlId as genPlId from tblEffectivities where (efTypeVer ='",
        Module1.newModule.TypeVer,
        "' and (",
        Conversions.ToString(Module1.newModule.effEnds),
        " between INT(efFrom ) and INT(efThru ) )) or ( efTypeVer = '999' and efThru like '999%' )) ORDER BY GENPLANNUMBER"
      }));
            int num2 = (aset.Tables[0].Rows.Count - 1);
            int i = 0;
            while ((i <= num2))
            {
                if (Module1.newModule.printall)
                {
                    Module1.newModule.PLANID = Conversions.ToInteger(aset.Tables[0].Rows[i]["genPlId"]);
                    string str = Conversions.ToString(aset.Tables[0].Rows[i]["genPlannumber"]);
                    frmWait.newfrmWait1.BringToFront();
                    frmWait.newfrmWait1.Text = "Prepairing cards for print .....";
                    frmWait.newfrmWait1.LabelControl2.Visible = true;
                    frmWait.newfrmWait1.ProgressBarControl1.Visible = true;
                    frmWait.newfrmWait1.ProgressBarControl1.Properties.Minimum = 1;
                    frmWait.newfrmWait1.ProgressBarControl1.Properties.Maximum = aset.Tables[0].Rows.Count;
                    frmWait.newfrmWait1.ProgressBarControl1.EditValue = (i + 1);
                    frmWait.newfrmWait1.ProgressBarControl1.Update();
                    frmWait.newfrmWait1.LabelControl2.Text = string.Concat(new string[] {
            "Adding card ",
            str,
            " to preview ..... Card ",
            Conversions.ToString((int)(i + 1)),
            " from ",
            Conversions.ToString(aset.Tables[0].Rows.Count)
          });
                    frmWait.newfrmWait1.LabelControl2.Refresh();
                    frmWait.newfrmWait1.Refresh();
                    Module1.newModule.AreaNo = Conversions.ToInteger(Conversion.Int(str.Substring(0, 2)));
                    Module1.newModule.PlanNumber = Conversions.ToString(Module1.newModule.PLANID);
                    if ((Module1.newModule.AreaNo == 50))
                    {
                        System.Windows.Forms.Application.DoEvents();

                    }
                    else if ((Module1.newModule.AreaNo == 30))
                    {
                        System.Windows.Forms.Application.DoEvents();
                        Module1.newModule.excist = true;
                        frmBackshopNew shopl = new frmBackshopNew();
                        shopl.Show();
                        shopl.Close();
                    }
                    else
                    {
                        frmOps ops = new frmOps();
                        System.Windows.Forms.Application.DoEvents();
                        Module1.newModule.editCard = true;
                        ops.Show();
                        ops.Close();
                    }
                }
                else
                {
                    this.Enabled = true;
                    return;
                }
                i += 1;
            }
            frmWait.newfrmWait1.Close();
            Module1.newModule.report1.Pages.AddRange(Module1.newModule.report3.Pages);
            Module1.newModule.report1.Pages.AddRange(Module1.newModule.report4.Pages);
            Module1.newModule.report1.Pages.AddRange(Module1.newModule.report2.Pages);
            Module1.newModule.report1.Pages.AddRange(Module1.newModule.report5.Pages);
            Module1.newModule.report1.ExportToPdf(Module1.newModule.exppdf);
            XtraMessageBox.Show(("File saved at : " + Module1.newModule.exppdf), "Save path.", MessageBoxButtons.OK);
            this.Enabled = true;
            Module1.newModule.printall = false;
        }





        //    If sender.pressedlink Is Nothing Then
        //        Exit Sub
        //    End If
        //    Dim dc As New clsData
        //    Dim ds As New DataSet
        //    If 1 = 2 Then
        //        XtraMessageBox.Show("Please select a TailNo first!", "ePlanViewerOman...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        //    Else

        //        Dim f As Form

        //        On Error Resume Next
        //        'For Each f In My.Application.OpenForms



        //        '    'Select Case f.Name
        //        '    '    'Case "frmCards"
        //        '    '    '    f.Close()
        //        '    '    'Case " frmOps"
        //        '    '    '    f.Close()
        //        '    '    'Case "frmElectrical"
        //        '    '    '    f.Close()
        //        '    '    'Case "frmBackShopl"
        //        '    '    '    f.Close()
        //        '    'End Select






        //        'Next f

        //        Select Case sender.PressedLink.ItemName

        //            Case "ops"
        //                AreaNo = 12
        //                TEAM = "OPS"
        //                Template = True
        //                frmOps.Text = "INDUCTION"
        //            Case "misc"
        //                AreaNo = 14
        //                TEAM = "MISCELLANEOUS"
        //                Template = True
        //                frmOps.Text = "MISCELLANEOUS"
        //            Case "rsheetmetals"
        //                AreaNo = 20
        //                TEAM = "SHEETMETALS"
        //                Template = True
        //                frmOps.Text = "REMOVE-SHEETMETALS"
        //            Case "rapg"
        //                AreaNo = 22
        //                TEAM = "APG"
        //                Template = True
        //                frmOps.Text = "REMOVE-APG"
        //            Case "relectrical"
        //                AreaNo = 24
        //                TEAM = "ELECTRICALS"
        //                Template = True
        //                frmOps.Text = "REMOVE-ELECTRICALS"
        //            Case "rmisc"
        //                AreaNo = 26
        //                TEAM = "MISCELLANEOUS"
        //                Template = True
        //                frmOps.Text = "REMOVE-MISC"
        //            Case "rwbackshop"
        //                AreaNo = 30
        //                TEAM = " BACKSHOP "
        //                frmBackshopNew.Text = "REWORK-BACKSHOP"
        //            Case "rwsheet"
        //                AreaNo = 40
        //                TEAM = "SHEETMETALS"
        //                Template = True
        //                frmOps.Text = "REWORK-SHEETMETALS"
        //            Case "rwelectrical"
        //                AreaNo = 50
        //                HarnSel = True
        //                TEAM = "ELECTRICAL"
        //                frmElectrical.Text = "REWORK-ELECTRICAL"
        //            Case "rwapg"
        //                AreaNo = 60
        //                TEAM = "APG"
        //                Template = True
        //                frmOps.Text = "REWORK-APG"
        //            Case "rwmisc"
        //                AreaNo = 70
        //                TEAM = "MISCELLANEOUS"
        //                Template = True
        //                frmOps.Text = "REWORK-MISC"
        //            Case "pmelectrical"
        //                TEAM = "ELECTRICALS"
        //                AreaNo = 80
        //                Template = True
        //                frmOps.Text = "POST MODIFICATION"
        //            Case "pmapg"
        //                AreaNo = 82
        //                TEAM = "APG"
        //                Template = True
        //                frmOps.Text = "POST MODIFICATION"
        //            Case "pmops"
        //                AreaNo = 84
        //                TEAM = "MISCELLANEOUS"
        //                Template = True
        //                frmOps.Text = "POST MODIFICATION"
        //            Case "pmpreflight"
        //                AreaNo = 86
        //                TEAM = "MISCELLANEOUS"
        //                Template = True
        //                frmOps.Text = "PREFLIGHT"
        //            Case "Cards"
        //                For Each f In My.Application.OpenForms

        //                    Select Case f.Name
        //                        Case "frmCards"
        //                            f.Close()
        //                    End Select
        //                Next f
        //                frmCards.MdiParent = Me
        //                frmCards.Show()


        //                ' AreaNo = 0
        //                Exit Sub
        //            Case "NavBarItem14"
        //                For Each f In My.Application.OpenForms



        //                    Select Case f.Name
        //                        Case "frmCrunch"
        //                            f.Close()

        //                    End Select
        //                Next f
        //                frmCrunch.Close()
        //                frmCrunch.MdiParent = Me
        //                frmCrunch.Show()
        //                Exit Sub
        //            Case "Mprs"
        //                Dim wait As New frmWait
        //                Dim dialog As New OpenFileDialog
        //                Dim data4 As New clsData
        //                'Control.CheckForIllegalCrossThreadCalls(False)
        //                Module1.excist = True
        //                Me.dsCrunch.Clear()
        //                Module1.Createadapter(Me.dsCrunch, "CBE", "Q", Me.daCBE)
        //                Module1.Createadapter(Me.dsCrunch, "PTP", "Q", Me.daPTP)
        //                Module1.Createadapter(Me.dsCrunch, "MPRS", "Q", Me.daMPRS)
        //                dialog.InitialDirectory = "c:\"
        //                dialog.Filter = "Microsoft Acess files (*.MDB)|*.MDB|All files (*.*)|*.*"
        //                If (dialog.ShowDialog = DialogResult.OK) Then
        //                    Module1.NAMF = dialog.FileName
        //                    Module1.Template = True
        //                    MprsUpdate()

        //                End If
        //                Exit Sub

        //            Case "TailParts"
        //                Dim ds3 As New DataSet
        //                Dim ds2 As New DataSet
        //                Dim frmas As New xrPartsPreview
        //                Dim dc3 As New clsData
        //                'ds = dc.getData("select genPlId,genTypeVer,genDescription,genPlannumber,prtPartNumberDoc,prtDescription from tblGeneral,tblAssembly where prtPlId =prtPlId and genPlId=prtPlId  and prtPartNumberDoc LIKE '" & txtSearch.Text.Trim & "%'")

        //                ' ds2 = dc.getData("select genPlId,genTypeVer,genDescription,genPlannumber,partnumber,DESCRIPTION from tblGeneral,tblrefdescomp where REFCOMPPLID =REFCOMPPLID and genPlId=REFCOMPPLID  and PARTNUMBER LIKE '" & txtSearch.Text.Trim & "%'")

        //                ds3 = dc3.getData("select genPlId,genTypeVer,genDescription,genPlannumber,prtPartNumberDoc,prtDescription,prtQty from tblGeneral,tblAssembly where prtAction ='ADD' and prtPlId =prtPlId and genPlId=prtPlId  and ((prtTypeVer ='" & TypeVer & "'and " & effEnds & " between prtFrom and prtThru ) or ( prtTypeVer = '999' and prtThru = 9999 ))and prtPartNumberDoc LIKE '" & txtSearch.Text.Trim & "%' and genPlId in([select] efPlId as genPlId from tblEffectivities where (efTypeVer ='" & TypeVer & "' and (" & effEnds & " between INT(efFrom ) and INT(efThru ) )) or ( efTypeVer = '999' and efThru like '999%' ))")

        //                ds2 = dc3.getData("select genPlId,genTypeVer,genDescription,genPlannumber,partnumber,DESCRIPTION,QTY from tblGeneral,tblrefdescomp where REFACTION ='ADD' AND REFCOMPPLID =REFCOMPPLID and genPlId=REFCOMPPLID  and PARTNUMBER LIKE '" & txtSearch.Text.Trim & "% 'and genPlId in([select] efPlId as genPlId from tblEffectivities where (efTypeVer ='" & TypeVer & "' and (" & effEnds & " between INT(efFrom ) and INT(efThru ) )) or ( efTypeVer = '999' and efThru like '999%' ))")
        //                'Createadapter(dsdrawings, "tblAssembly", "prtPlId = '" & PlanNumber & "' and ((prtTypeVer ='" & TypeVer & "'and " & effEnds & " between prtFrom and prtThru ) or ( prtTypeVer = '999' and prtThru = 9999 ))", daAssemply)
        //                ' Createadapter(dsElectrical, "tblAssembly", "prtPlId = '" & PlanNumber & "' and ((prtTypeVer ='" & TypeVer & "'and " & effEnds & " between prtFrom and prtThru ) or ( prtTypeVer = '999' and prtThru = 9999 ))", daAssemply)

        //                ds2.Tables(0).Columns(4).ColumnName = "prtPartNumberDoc"
        //                ds2.Tables(0).Columns(5).ColumnName = "prtDescription"
        //                ds2.Tables(0).Columns(6).ColumnName = "prtQty"
        //                ds3.Merge(ds2)
        //                If txtSearch.Text = "" Then
        //                    frmas.Text = "External view search "
        //                Else
        //                    frmas.Text = "Results for '' " & txtSearch.Text & "''"
        //                    ' frmas.MdiParent = Me
        //                End If

        //                frmas.GridControl1.DataSource = ds3.Tables(0)
        //                frmas.GridView1.BestFitColumns()
        //                frmas.txtHandling.Text = docHandling
        //                frmas.txtDesPage.Text = "Parts preview for " & TailNo & "  T/V : " & TypeVer & " - " & effEnds
        //                frmas.ShowPreviewDialog()
        //                ''Dim dc As New clsData
        //                ''Dim ds As New DataSet
        //                ''Dim frm As New frmSearch


        //                ''ds = dc.getData("select * from tblGeneral,tblAssembly where genPlId =genPlId and prtPlId=genPlId and prtPartNumberDoc LIKE '" & txtSearch.Text.Trim & "%'")

        //                ''frm.MdiParent = Me
        //                ''frm.gridSearchResult.DataSource = ds.Tables(0)

        //                ''frm.Show()
        //            Case "oil"
        //                AreaNo = 0
        //                Dim frma As New frmCards
        //                frma.MdiParent = Me
        //                '  frma.Text = "CARDS FOR " & cmbCountry.Text
        //                frma.Show()

        //                Dim xr As New xrOil
        //                xr.txtCountry.Text = txtCountry.Text
        //                xr.txtDate.Text = Date.Today

        //                xr.txtProgram.Text = cmbProgram.Text
        //                '    xr.XrTableCell4.Text = "OIL FOR " & cmbCountry.Text
        //                'xr.txtTailNo.Text = cmbCountry.Text
        //                xr.txtType.Text = TypeVer & " - " & effEnds
        //                xr.grdOil.DataSource = frma.dsCards.Tables("tblGeneral")

        //                xr.ShowPreview()
        //            Case "Import"
        //                ' Dim dsexport As New DataSet
        //                PlanNumber = Guid.NewGuid.ToString
        //                Createadapter(dsExport, "tblBackShopWires", "bacPlId ='" & PlanNumber & "'", daTransferBackShop)
        //                '
        //                Createadapter(dsExport, "tblCont", "bacPlId ='" & PlanNumber & "'", daTransferCont)
        //                '
        //                Createadapter(dsExport, "tblDrawings", "DwgPlId ='" & PlanNumber & "'", daTransferDrawings)
        //                '
        //                Createadapter(dsExport, "tblTools", "tlPlid ='" & PlanNumber & "'", daTransferTools)
        //                '
        //                Createadapter(dsExport, "tblEffectivities", "efPlId = '" & PlanNumber & "'", daTransferEffectivities)
        //                '
        //                Createadapter(dsExport, "tblGeneral", "genPlId = '" & PlanNumber & "'", daTransferGeneral)
        //                '
        //                Createadapter(dsExport, "tblmisc", "miscPlId = '" & PlanNumber & "'", daTransferMisc)
        //                '
        //                Createadapter(dsExport, "tblNotes", "plNotesId = '" & PlanNumber & "'", daTransferNotes)
        //                '
        //                Createadapter(dsExport, "tblPlano", "PlannoId = '" & PlanNumber & "'", daTransferPlano)
        //                '
        //                Createadapter(dsExport, "tblRefDes", "RefPlanId = '" & PlanNumber & "'", daTransferRefDes)
        //                '
        //                Createadapter(dsExport, "tblRefDesComp", "REFCOMPPLID ='" & PlanNumber & "'", daTransferRefDesComp)
        //                '
        //                Createadapter(dsExport, "tblRoute", "rPlId ='" & PlanNumber & "'", daTransferRoute)
        //                '
        //                Createadapter(dsExport, "tblSelHarness", "hrnSelPlId ='" & PlanNumber & "'", daTransferSelHarness)
        //                '
        //                Createadapter(dsExport, "tblTemplate", "tmpPlid ='" & PlanNumber & "'", daTransferTemplate)

        //                Createadapter(dsExport, "tblAssembly", "prtPlId = '" & PlanNumber & "'", daTransferAssembly)
        //                '
        //                Createadapter(dsExport, "tblWires", " WIRESPLID ='" & PlanNumber & "'", daTransferWires)
        //                '
        //                Createadapter(dsExport, "tblWiresAdd", " WIRESPLID ='" & PlanNumber & "'", daTransferWiresAdd)
        //                '
        //                Createadapter(dsExport, "tblWiresRemove", " WIRESPLID ='" & PlanNumber & "'", daTransferWiresRemove)
        //                '
        //                Createadapter(dsExport, "tblWiresRevise", " WIRESPLID ='" & PlanNumber & "'", daTransferWiresRevise)
        //                '
        //                Createadapter(dsExport, "tblMisc", " miscplid ='" & PlanNumber & "'", daTransferMisc)
        //                '
        //                Createadapter(dsExport, "tblWiresBackshell", " WIRESPLID ='" & PlanNumber & "'", daTransferWiresBackshell)
        //                Dim dialog As New OpenFileDialog
        //                Dim DSNEW As New DataSet
        //                Dim DSSCH As New DataSet
        //                dialog.Filter = "xml files (*.xml)|*.xml"

        //                If (dialog.ShowDialog = DialogResult.OK) Then
        //                    Dim FileName As String = dialog.FileName

        //                    '  dsexport = New DataSet


        //                    dsExport.ReadXmlSchema(FileName)
        //                    DSNEW.ReadXmlSchema(Application.StartupPath & "\test.XML")
        //                    DSNEW.ReadXml(FileName)


        //                    dsExport = DSNEW.Copy

        //                    'Dim dst As DataSet = DirectCast(bdGeneralOps.DataSource, DataSet)

        //                    'Dim drt As DataRow = dst.Tables("tblGeneral").Rows(bdGeneralOps.Position)

        //                    ' txtPartNumber.Text = STRPLANO

        //                    '         dsdrawings.Tables("tblGeneral").Merge(bdGeneralOps.DataSource)
        //                    daTransferGeneral.Update(dsExport, "tblGeneral")
        //                    Dim plannew As String
        //                    Dim drc As New clsData
        //                    plannew = dsExport.Tables("tblGeneral").Rows(0).Item("genPlId")
        //                    Dim dsas As DataSet
        //                    dsas = drc.getData("select * from tblplano where plannoid ='" & plannew & "'")
        //                    Dim descx As Integer
        //                    Dim ar As Integer
        //                    Dim sda As New DataSet
        //                    Dim strarea As String
        //                    If dsas.Tables(0).Rows.Count = 0 Then

        //                        'AreaNo = dsExport.Tables("tblGeneral").Rows(0).Item("genPlanNumber")
        //                        strarea = dsExport.Tables("tblGeneral").Rows(0).Item("genPlanNumber")
        //                        strarea = strarea.Substring(0, 2)
        //                        ar = strarea
        //                        sda = drc.getData(" select max (description) AS maxid1 from tblplano where AreaNo = " & strarea)
        //                        If sda.Tables(0).Rows(0)("maxid1") Is DBNull.Value Then
        //                            strPlannumber = 1
        //                        Else
        //                            strPlannumber = sda.Tables(0).Rows(0)("maxid1") + 1
        //                        End If
        //                        descx = strPlannumber
        //                        STRPLANO = strarea & "-" & CStr(strPlannumber).PadLeft(3, "0")
        //                        drc.ExecuteSQL("update tblGeneral set  genPlanNumber ='" & STRPLANO & " 'where genPlId = '" & plannew & "'")
        //                        'dc.ExecuteSQL("update tblPlano set  PlannoId ='" & planNew & " 'where PlannoId = '" & PlanNumber & "'")


        //                        '   XtraMessageBox.Show(ex.Message)

        //                    Else
        //                        'STRPLANO = dsas.Tables(0).Rows(0).Item("AreaNo")
        //                        'XtraMessageBox.Show("This card already exists on db")
        //                        'Exit Sub
        //                        Dim sql4 As String
        //                        Dim dc4 As New clsData
        //                        Dim ans As DialogResult


        //                        ' dc.ExecuteSQL("update tblGeneral set  genPlid ='999999999' where genPlId = '" & plannew & "'")

        //                        dc4.ExecuteSQL("DELETE * FROM PDFWIRE1 WHERE pdfplid1 = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM PDFWIRE2 WHERE pdfplid2 = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLASSEMBLY WHERE prtPlid = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLBACKSHOPWIRES WHERE bacPlId = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLCONT WHERE bacPlId = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLDRAWINGS WHERE DwgPlId = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLGENERAL WHERE genPlId = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLMISC WHERE MISCPLANID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLNOTES WHERE  plNotesId = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLPARTS WHERE PARTSPLID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLPARTSCONSUM WHERE conPlId = '" & plannew & "'")
        //                        'Try
        //                        '    sql = (String.Format("UPDATE tblPlano SET  AreaNo = {0} where PlannoId ='{1}'", 999, plannew))
        //                        '    dc.ExecuteSQL(sql)
        //                        'Catch ex As Exception
        //                        '    XtraMessageBox.Show(ex.ToString)

        //                        'End Try

        //                        dc4.ExecuteSQL("DELETE * FROM TBLPLANO WHERE PlannoId = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLREFDES WHERE RefPlanId = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLREFDESCOMP WHERE REFCOMPPLID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLROUTE WHERE  rPlId= '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLTEMPLATE WHERE tmpPlid = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLTOOLS WHERE tlPlid = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLWIRES WHERE WIRESPLID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLHARNESS WHERE HPLID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLEFFECTIVITIES WHERE efPlId = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLWIRESREMOVE WHERE WIRESPLID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLWIRESADD WHERE WIRESPLID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLWIRESREVISE WHERE WIRESPLID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM tblWiresBackshell WHERE WIRESPLID = '" & plannew & "'")
        //                        dc4.ExecuteSQL("DELETE * FROM TBLselHARNESS WHERE hrnSelPlId = '" & plannew & "'")
        //                    End If

        //                    ' ''Dim descx As Integer
        //                    ' ''Dim ar As Integer
        //                    ' ''Dim sda As New DataSet
        //                    ' ''Dim strarea As String
        //                    '' ''AreaNo = dsExport.Tables("tblGeneral").Rows(0).Item("genPlanNumber")
        //                    ' ''strarea = dsexport.Tables("tblGeneral").Rows(0).Item("genPlanNumber")
        //                    ' ''strarea = strarea.Substring(0, 2)
        //                    ' ''ar = strarea
        //                    ' ''sda = drc.getData(" select max (description) AS maxid1 from tblplano where AreaNo = " & strarea)
        //                    ' ''If sda.Tables(0).Rows(0)("maxid1") Is DBNull.Value Then
        //                    ' ''    strPlannumber = 1
        //                    ' ''Else
        //                    ' ''    strPlannumber = sda.Tables(0).Rows(0)("maxid1") + 1
        //                    ' ''End If
        //                    ' ''descx = strPlannumber
        //                    ' ''STRPLANO = strarea & "-" & CStr(strPlannumber).PadLeft(3, "0")
        //                    ' ''drc.ExecuteSQL("update tblGeneral set  genPlanNumber ='" & STRPLANO & " 'where genPlId = '" & plannew & "'")
        //                    '' ''dc.ExecuteSQL("update tblPlano set  PlannoId ='" & planNew & " 'where PlannoId = '" & PlanNumber & "'")


        //                    '   XtraMessageBox.Show(ex.Message)


        //                    daTransferAssembly.Update(dsExport, "tblAssembly")
        //                    daTransferBackShop.Update(dsExport, "tblBackShopWires")
        //                    daTransferCont.Update(dsExport, "tblCont")
        //                    daTransferDrawings.Update(dsExport, "tblDrawings")
        //                    daTransferEffectivities.Update(dsExport, "tblEffectivities")
        //                    daTransferGeneral.Update(dsExport, "tblGeneral")
        //                    ' drc.ExecuteSQL("update tblGeneral set  genPlanNumber ='" & STRPLANO & " 'where genPlId = '" & plannew & "'")

        //                    daTransferMisc.Update(dsExport, "tblMisc")
        //                    daTransferNotes.Update(dsExport, "tblNotes")
        //                    daTransferRefDes.Update(dsExport, "tblRefDes")
        //                    daTransferRefDesComp.Update(dsExport, "tblRefDesComp")
        //                    daTransferRoute.Update(dsExport, "tblRoute")
        //                    daTransferSelHarness.Update(dsExport, "tblSelHarness")
        //                    daTransferTemplate.Update(dsExport, "tblTemplate")
        //                    daTransferTools.Update(dsExport, "tblTools")
        //                    daTransferWires.Update(dsExport, "tblWires")
        //                    daTransferWiresAdd.Update(dsExport, "tblWiresAdd")
        //                    daTransferWiresBackshell.Update(dsExport, "tblWiresBackShell")
        //                    daTransferWiresRemove.Update(dsExport, "tblWiresRemove")
        //                    daTransferWiresRevise.Update(dsExport, "tblWiresRevise")
        //                    daTransferPlano.Update(dsExport, "tblPlano")
        //                    drc.ExecuteSQL("update tblPlano set  AreaNo =" & ar & " ,Description = " & descx & " where PlannoId = '" & PlanNumber & "'")

        //                    Dim dsref As New DataSet
        //                    Dim dcref As New clsData
        //                    dsref = dcref.getData("SELECT DISTINCT REFDES,REFDESID FROM TBLREFDES WHERE REFPLANID = '" & plannew & "'")
        //                    For I = 0 To dsref.Tables(0).Rows.Count - 1
        //                        RefDesId = dsref.Tables(0).Rows(I)("REFDESID")
        //                        RefDes = dsref.Tables(0).Rows(I)("REFDES")
        //                        dcref.ExecuteSQL("UPDATE TBLWIRES SET WREFDESID = '" & RefDesId & "' WHERE SREFDES = '" & RefDes & "' AND WIRESPLID ='" & plannew & "'")
        //                        dcref.ExecuteSQL("UPDATE TBLWIRESADD SET WREFDESID = '" & RefDesId & "' WHERE SREFDES = '" & RefDes & "' AND WIRESPLID ='" & plannew & "'")
        //                        dcref.ExecuteSQL("UPDATE TBLWIRESREMOVE SET WREFDESID = '" & RefDesId & "' WHERE SREFDES = '" & RefDes & "' AND WIRESPLID ='" & plannew & "'")
        //                        dcref.ExecuteSQL("UPDATE TBLWIRESREVISE SET WREFDESID = '" & RefDesId & "' WHERE SREFDES = '" & RefDes & "' AND WIRESPLID ='" & plannew & "'")
        //                        dcref.ExecuteSQL("UPDATE TBLWIRESBACKSHELL SET WREFDESID = '" & RefDesId & "' WHERE SREFDES = '" & RefDes & "' AND WIRESPLID ='" & plannew & "'")



        //                    Next
        //                    Dim DCD As New clsData
        //                    Dim DSDR As New DataSet
        //                    DSDR = DCD.getData("SELECT * FROM TBLDRAWINGS WHERE DwgPlId ='" & plannew & "'")
        //                    For I = 0 To DSDR.Tables(0).Rows.Count - 1
        //                        Dim ECNA As String
        //                        Dim TCV As String
        //                        Dim DRF As Integer
        //                        Dim DRT As Integer
        //                        Dim DRPA As String
        //                        DRPA = DSDR.Tables(0).Rows(I).Item("dwgPartnumber")
        //                        ECNA = DSDR.Tables(0).Rows(I).Item("dwgEcn")
        //                        TCV = DSDR.Tables(0).Rows(I).Item("dwgTypever")
        //                        DRF = DSDR.Tables(0).Rows(I).Item("dwgFrom")
        //                        DRT = DSDR.Tables(0).Rows(I).Item("dwgThru")

        //                        Dim DSCOMMENT As New DataSet
        //                        Dim DCCOMMENT As New clsData
        //                        Dim OLDDRTEXTA As String
        //                        Dim NEWDRTEXT As String
        //                        Dim CD As New clsData
        //                        If TCV = "999" Then
        //                            Dim JK As Integer
        //                            Dim JD As Integer
        //                            JK = ECNA.IndexOf("-")
        //                            JD = DRPA.IndexOf("-")
        //                            If JK = -1 Then
        //                            Else
        //                                ECNA = ECNA.Substring(JK + 1)

        //                            End If
        //                            If JD = -1 Then
        //                            Else

        //                                DRPA = DRPA.Substring(0, JD)
        //                            End If

        //                            DSCOMMENT = DCCOMMENT.getData("SELECT COMMENT FROM TBLECN WHERE DRAWING='" & DRPA & "' AND ECN ='" & ECNA & "'")
        //                            For J = 0 To DSCOMMENT.Tables(0).Rows.Count - 1


        //                                ecnComment = DSCOMMENT.Tables(0).Rows(J).Item("COMMENT")
        //                                stath = ecnComment
        //                                If ecnComment.Contains(STRPLANO) Then
        //                                Else
        //                                    If ecnComment.Contains("Started Pl/c ") Then
        //                                        ecnComment = ecnComment.Replace("Started Pl/c ", "Started Pl/c " & STRPLANO & " ,")
        //                                    Else
        //                                        ecnComment = "Started Pl/c  " & STRPLANO
        //                                    End If
        //                                    CD.ExecuteSQL("UPDATE tblEcn set  comment ='" & ecnComment & " 'where COMMENT = '" & stath & "' AND ECN ='" & ECNA & "'")

        //                                End If
        //                                'If ecnComment.Trim = "Started Pl/c " & txtPartNumber.Text Then
        //                                '    NEWDRTEXT = "Finished Pl/c " & txtPartNumber.Text
        //                                '    stath = ecnComment.Replace(ecnComment, NEWDRTEXT)
        //                                'ElseIf ecnComment.Contains("Finished Pl/c") Then
        //                                '    stath = ecnComment.Replace("Finished Pl/c", "Finished Pl/c " & txtPartNumber.Text & " , ")
        //                                'Else
        //                                '    stath = ecnComment.Replace(STRPLANO, "")
        //                                '    stath = ecnComment & "  AND Finished Pl/c " & txtPartNumber.Text
        //                                'End If

        //                                'ds = cd.getData("select comment FROM TBLECN WHERE ecn = '" & stath & "'", ni) ' Application.StartupPath & "\dbMain.mdb") 'OR DESCRIPTION ='WAFER' OR DESCRIPTION = 'CONNECTOR' "

        //                                'ecnComment = ds.Tables(0).Rows(0)("COMMENT")

        //                                'oldtext = "Started Pl/c " & STRPLANO
        //                                'newtext = "Finished Pl/c " & STRPLANO
        //                                'ecnComment = ecnComment.Replace(oldtext, newtext)
        //                                '' cd.ExecuteSQL("UPDATE tblEcn set  comment ='" & " Finished Pl/c " & STRPLANO & " 'where DRAWING = '" & stath & "'")

        //                                'SAMEECN = stath


        //                            Next
        //                        Else
        //                            DSCOMMENT = DCCOMMENT.getData("SELECT COMMENT FROM TBLECN WHERE DRAWING='" & DRPA & "' AND ECN ='" & ECNA & "' AND TYPEVER ='" & TCV & "' AND FR0M = '" & CStr(DRF).PadLeft(4, "0") & "' AND THRU ='" & CStr(DRT).PadLeft(4, "0") & "'")
        //                            For J = 0 To DSCOMMENT.Tables(0).Rows.Count - 1


        //                                ecnComment = DSCOMMENT.Tables(0).Rows(J).Item("COMMENT")
        //                                stath = ecnComment
        //                                If ecnComment.Contains(STRPLANO) Then
        //                                Else
        //                                    If ecnComment.Contains("Started Pl/c") Then
        //                                        ecnComment = ecnComment.Replace("Started Pl/c", "Started Pl/c " & STRPLANO & " ,")
        //                                    Else
        //                                        ecnComment = "Started Pl/c  " & STRPLANO
        //                                    End If
        //                                    CD.ExecuteSQL("UPDATE tblEcn set  comment ='" & ecnComment & " 'where COMMENT = '" & stath & "' AND ECN ='" & ECNA & "'")

        //                                End If
        //                                'If ecnComment.Trim = "Started Pl/c " & txtPartNumber.Text Then
        //                                '    NEWDRTEXT = "Finished Pl/c " & txtPartNumber.Text
        //                                '    stath = ecnComment.Replace(ecnComment, NEWDRTEXT)
        //                                'ElseIf ecnComment.Contains("Finished Pl/c") Then
        //                                '    stath = ecnComment.Replace("Finished Pl/c", "Finished Pl/c " & txtPartNumber.Text & " , ")
        //                                'Else
        //                                '    stath = ecnComment.Replace(STRPLANO, "")
        //                                '    stath = ecnComment & "  AND Finished Pl/c " & txtPartNumber.Text
        //                                'End If

        //                                'ds = cd.getData("select comment FROM TBLECN WHERE ecn = '" & stath & "'", ni) ' Application.StartupPath & "\dbMain.mdb") 'OR DESCRIPTION ='WAFER' OR DESCRIPTION = 'CONNECTOR' "

        //                                'ecnComment = ds.Tables(0).Rows(0)("COMMENT")

        //                                'oldtext = "Started Pl/c " & STRPLANO
        //                                'newtext = "Finished Pl/c " & STRPLANO
        //                                'ecnComment = ecnComment.Replace(oldtext, newtext)
        //                                '' cd.ExecuteSQL("UPDATE tblEcn set  comment ='" & " Finished Pl/c " & STRPLANO & " 'where DRAWING = '" & stath & "'")

        //                                'SAMEECN = stath


        //                            Next
        //                        End If


        //                    Next
        //                    XtraMessageBox.Show("Import completed")
        //                    Exit Sub
        //                Else
        //                    Exit Sub


        //                End If

        //            Case Else
        //                Exit Sub

        //        End Select

        //        'Dim frm As New frmCards
        //        'frm.MdiParent = Me
        //        ''   frm.Text = "CARDS FOR " & cmbCountry.Text


        //        Dim sql As String
        //        Dim frmno As New frmPLANNUMBER

        //        'Set Number of planning card
        //        sql = (" select max (description) AS maxid1 from tblplano where AreaNo =" & AreaNo)
        //        ds = dc.getData(sql)
        //        If ds.Tables(0).Rows(0)("maxid1") Is DBNull.Value Then
        //            strPlannumber = 1
        //        Else
        //            strPlannumber = ds.Tables(0).Rows(0)("maxid1") + 1
        //        End If

        //        'sql = (" select max (plannoid)AS maxid from tblplano")
        //        'ds = dc.getData(sql, ni)
        //        'If ds.Tables(0).Rows(0)("maxid") Is DBNull.Value Then
        //        '    PlanNumber = 1
        //        'Else
        //        '    PlanNumber = ds.Tables(0).Rows(0)("maxid") + 1
        //        'End If
        //        plnumber = (Guid.NewGuid.ToString).Trim
        //        PlanNumber = plnumber




        //        'check if ecn is selected
        //        Dim dcdrw As New clsData
        //        If startinG = True Then

        //            'dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru) VALUES ( '" & PlanNumber & "' & ",'" & DrwNo & "-" & strEcn & "','ECN " & "-" & TITLE & "','" & DRWREV & "','" & TypeVer & "'," & FRMO & "," & THRU & ")")
        //            'dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru) VALUES ( '" & PlanNumber & "' & ",'" & DrwNo & "','B/P " & "-" & TITLE & "','" & DRWREV & "','" & TypeVer & "'," & FRMO & "," & THRU & ")")
        //            dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '" & plnumber & "','" & DrwNo & "-" & strEcn & "','ECN','" & DRWREV & "','" & tv & "'," & fr & "," & trhu & ",'" & strEcn & "','Started Pl/c " & STRPLANO & "')")

        //            ' dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '" & PlanNumber & "','" & DrwNo & "-" & strEcn & "','ECN','" & DRWREV & "','" & typever & "'," & FRMO & "," & thru & ",'" & strEcn & "','Started Pl/c " & STRPLANO & "')")
        //            If DrwNo Like "*H16DW*" Then

        //            Else
        //                dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '" & plnumber & "','" & DrwNo & "-" & strEcn & "','ECN','" & DRWREV & "','" & tv & "'," & fr & "," & trhu & ",'" & strEcn & "','Started Pl/c " & STRPLANO & "')")

        //                dcdrw.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '" & plnumber & "','" & DrwNo & "','B/P','" & DRWREV & "','" & tv & "'," & fr & "," & trhu & ",'" & strEcn & "','Started Pl/c " & STRPLANO & "')")
        //            End If

        //            'dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES) VALUES ( '" & PlanNumber & "' & ",'" & plEcn & "','ECN " & TITLE & "','" & DRWREV & "')")

        //        Else
        //            txtDrawing.Text = ""
        //            If Template = False Then
        //                XtraMessageBox.Show("YOU MUST DOUBLE CLICK ON A ECN TO START")
        //                Exit Sub
        //            End If
        //        End If

        //        If Template = False Then
        //            frmno.plano.Text = strPlannumber
        //            frmno.plano.Text = frmno.plano.Text.PadLeft(3, "0")

        //            'If strPlannumber > 99 Then
        //            '    frmno.plano.Text = CStr(strPlannumber)
        //            'Else
        //            '    If strPlannumber > 9 Then
        //            '        frmno.plano.Text = ("0" & strPlannumber)
        //            '    Else
        //            '        frmno.plano.Text = ("00" & strPlannumber)
        //            '    End If

        //            'End If
        //            planoAgain = frmno.plano.Text
        //            frmno.txtArea.Text = CStr(AreaNo)
        //            STRPLANO = CStr(AreaNo) & "-" & planoAgain
        //            '  dc.ExecuteSQL("INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES) VALUES ( '" & PlanNumber & "' & ",'" & strEcn & "','ECN " & TITLE & "','" & DRWREV & "')")

        //            startinG = False
        //            Using FRM As New frmSel()
        //                FRM.lblStrECN.Visible = True
        //                FRM.txtStartEcn.Visible = True
        //                FRM.txtStartEcn.Text = DrwNo & " - " & txtDrawing.Text
        //                FRM.lblEcn.Text = strEcn
        //                FRM.ShowDialog()
        //            End Using
        //            frmno.ShowDialog()
        //            If FormCloseex = True Then
        //                Exit Sub
        //            End If
        //            Template = False
        //            If AreaNo = 50 Then
        //                If HarnSel = True Then
        //                    HarnSel = False
        //                    Dim frmHarnSel As New frmHarness

        //                    frmHarnSel.ShowDialog()
        //                End If
        //                If FormCloseex = True Then

        //                Else
        //                    dc.ExecuteSQL("INSERT INTO tblEffectivities(efPlid,efTypeVer,efFrom,efThru) VALUES ( '" & PlanNumber & "','" & TypeVer & "','" & FRMO & "','" & THRU & "')")
        //                    dc.ExecuteSQL("INSERT INTO TBLPLANO(PlannoId,AREANO,DESCRIPTION,revchng,typeVer,Program,plFrom,plThru) VALUES ('" & PlanNumber & "'," & AreaNo & "," & strPlannumber & ",'" & EFFECTIVITIES & "','','" & cmbProgram.Text & "','','')")

        //                    Application.DoEvents()
        //                    frmWait.MdiParent = Me
        //                    frmWait.Show()
        //                    Dim Frme As New frmElectrical


        //                    Frme.MdiParent = Me
        //                    excist = False
        //                    Frme.Text = STRPLANO

        //                    Frme.Show()

        //                End If

        //            Else
        //                Dim frm As New frmBackshopNew
        //                backshop = True
        //                frm.MdiParent = Me
        //                frm.Text = STRPLANO
        //                frm.Show()

        //            End If


        //        Else
        //            'If strPlannumber > 99 Then
        //            '    frmno.plano.Text = CStr(strPlannumber)
        //            'Else
        //            '    If strPlannumber > 9 Then
        //            '        frmno.plano.Text = ("0" & strPlannumber)
        //            '    Else
        //            '        frmno.plano.Text = ("00" & strPlannumber)
        //            '    End If

        //            'End If
        //            frmno.plano.Text = strPlannumber
        //            frmno.plano.Text = frmno.plano.Text.PadLeft(3, "0")
        //            frmno.txtArea.Text = CStr(AreaNo)
        //            Dim ans As DialogResult
        //            Dim selectedstaht As Boolean
        //            If startinG = False Then

        //                ans = XtraMessageBox.Show("Associate ECN with this Planning Card ?", "Creating", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        //                OpsEcn = True
        //            Else
        //                ans = XtraMessageBox.Show("Ecn -'" & strEcn & "'- already selected associate more ECN(s) with this Planning Card ?", "Creating", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        //                selectedstaht = True

        //                startinG = False
        //            End If
        //            If ans = Windows.Forms.DialogResult.Yes Then

        //                frmno.txtArea.Text = CStr(AreaNo)
        //                STRPLANO = CStr(AreaNo) & "-" & frmno.plano.Text
        //                startinG = False
        //                Using FRM As New frmSel()
        //                    FRM.lblStrECN.Visible = True
        //                    FRM.txtStartEcn.Visible = True
        //                    FRM.txtStartEcn.Text = DrwNo & " - "
        //                    FRM.lblEcn.Text = strEcn
        //                    FRM.ShowDialog()
        //                End Using
        //            Else
        //                If selectedstaht = True Then

        //                Else
        //                    TITLE = Nothing
        //                    ' txtDrawing.Text = ""
        //                    stath = "Nothing"
        //                End If

        //                frmno.txtArea.Text = CStr(AreaNo)

        //                TypeVer = "999"
        //                FRMO = 1
        //                THRU = 999
        //                STRPLANO = CStr(AreaNo) & "-" & frmno.plano.Text
        //                'If ecnComment.Contains(STRPLANO) Then

        //                'Else

        //                '    ecnComment += ","
        //                '    startinG = False
        //                '    ecnComment += " Started Pl/c " & STRPLANO
        //                dc.ExecuteSQL("UPDATE tblEcn set  comment ='" & ecnComment & "Started Pl/c " & STRPLANO & " 'where DRAWING = '" & DrwNo & "' and ECN = '" & stath & "'  AND DASH ='" & DRWREV & "' AND TYPEVER ='" & TypeVer & "' AND FR0M ='" & strFrmo & "' AND THRU='" & strTHRU & "'")

        //                'End If
        //                startinG = False
        //            End If

        //            '    frmno.plano.Text = PlanNumber
        //            frmno.ShowDialog()
        //            Template = False
        //            If FormCloseex = True Then

        //            Else
        //                dc.ExecuteSQL("INSERT INTO TBLPLANO(PlannoId,AREANO,DESCRIPTION,revchng,typeVer,Program,plFrom,plThru) VALUES ('" & PlanNumber & "'," & AreaNo & "," & strPlannumber & ",'" & EFFECTIVITIES & "','','" & cmbProgram.Text & "','','')")
        //                dc.ExecuteSQL("INSERT INTO tblEffectivities(efPlid,efTypeVer,efFrom,efThru) VALUES ( '" & PlanNumber & "','" & TypeVer & "','" & FRMO & "','" & THRU & "')")


        //                Dim Frm As New frmOps
        //                Frm.MdiParent = Me
        //                Frm.Show()
        //            End If

        //        End If
        //    End If
        //    frmWait.Close()
        //    'frmCards.MdiParent = Me
        //    'frmCards.Show()
        private void fixdb()
        {

            // XtraMessageBox.Show("DB IS CLEARED FROM OBSOLETTE /CURRENT", "'", MessageBoxButtons.OK)
        }

        private static void MprsUpdate()
        {
            // SimpleButton5.PerformClick()


            //'
            Module1.newModule.ISRUNN = true;
            System.Windows.Forms.Application.DoEvents();
            string Sqlstmt1 = "ALTER TABLE MPRS Add Column PART_NUMBER Text(50)";
            string Sqlstmt2 = "UPDATE MPRS SET PART_NUMBER = [PART NUMBER]";
            string Sqlstmt3 = "Alter table MPRS drop column [PART NUMBER]";
            System.Data.OleDb.OleDbConnection AccessConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Module1.newModule.NAMF);
            System.Data.OleDb.OleDbConnection AccessConnection1 = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Module1.newModule.NAMF);
            System.Data.OleDb.OleDbConnection AccessConnection2 = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Module1.newModule.NAMF);
            System.Data.OleDb.OleDbConnection AccessConnection3 = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Module1.newModule.NAMF);
            OleDbTransaction trans;//JMR -- look at -- took OleDb. off OleDb.OleDbTransaction 


            try
            {
                AccessConnection.Open();
                trans = AccessConnection.BeginTransaction();
                try
                {
                    System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand(Sqlstmt1, AccessConnection);
                    AccessCommand.Transaction = trans;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt2;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt3;
                    AccessCommand.ExecuteNonQuery();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
            }
            catch (Exception ex)
            {
                //XtraMessageBox.Show(ex.Message)
            }
            finally
            {
                AccessConnection.Close();
            }
            Sqlstmt1 = "ALTER TABLE MPRS Add Column DWG_ZONE Text(50)";
            Sqlstmt2 = "UPDATE MPRS SET  DWG_ZONE = [DWG ZONE]";
            Sqlstmt3 = "Alter table MPRS drop column [DWG ZONE]";

            try
            {
                AccessConnection.Open();
                trans = AccessConnection.BeginTransaction();
                try
                {
                    System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand(Sqlstmt1, AccessConnection);
                    AccessCommand.Transaction = trans;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt2;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt3;
                    AccessCommand.ExecuteNonQuery();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
            }
            catch (Exception ex)
            {
                //  XtraMessageBox.Show(ex.Message)
            }
            finally
            {
                AccessConnection.Close();
            }
            Sqlstmt1 = "ALTER TABLE MPRS Add Column DWG_ZONE Text(50)";
            Sqlstmt2 = "UPDATE MPRS SET  DWG_ZONE = [DWG ZONE]";
            Sqlstmt3 = "Alter table MPRS drop column [DWG ZONE]";

            try
            {
                AccessConnection.Open();
                trans = AccessConnection.BeginTransaction();
                try
                {
                    System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand(Sqlstmt1, AccessConnection);
                    AccessCommand.Transaction = trans;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt2;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt3;
                    AccessCommand.ExecuteNonQuery();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
            }
            catch (Exception ex)
            {
                //  XtraMessageBox.Show(ex.Message)
            }
            finally
            {
                AccessConnection.Close();
            }
            Sqlstmt3 = "Alter table MPRS drop column [UPDATE]";
            try
            {
                AccessConnection.Open();
                trans = AccessConnection.BeginTransaction();
                try
                {
                    System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand(Sqlstmt3, AccessConnection);
                    AccessCommand.Transaction = trans;
                    AccessCommand.ExecuteNonQuery();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
            finally
            {
                AccessConnection.Close();
            }
            //'
            Sqlstmt1 = "ALTER TABLE CBE Add Column DWG_DASH Text(50)";
            Sqlstmt2 = "UPDATE CBE SET  DWG_DASH = [DWG-DASH]";
            Sqlstmt3 = "Alter table CBE drop column [DWG-DASH]";
            string Sqlstmt4 = "ALTER TABLE CBE Add Column REF_DES Text(50)";
            string Sqlstmt5 = "UPDATE CBE SET REF_DES = [REF-DES]";
            string Sqlstmt6 = "Alter table CBE drop column [REF-DES]";
            string Sqlstmt7 = "ALTER TABLE CBE Add Column PTNUMBER Text(50)";
            string Sqlstmt8 = "UPDATE CBE SET PTNUMBER = [PT NUMBER]";
            string Sqlstmt9 = "Alter table CBE drop column [PT NUMBER]";
            string Sqlstmt10 = "ALTER TABLE CBE Add Column REFDESENDPT Text(50)";
            string Sqlstmt11 = "UPDATE CBE SET REFDESENDPT = [REF DES END PT]";
            string Sqlstmt12 = "Alter table CBE drop column [REF DES END PT]";
            try
            {
                AccessConnection.Open();
                trans = AccessConnection.BeginTransaction();
                try
                {
                    System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand(Sqlstmt1, AccessConnection);
                    AccessCommand.Transaction = trans;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt2;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt3;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt4;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt5;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt6;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt7;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt8;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt9;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt10;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt11;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt12;
                    AccessCommand.ExecuteNonQuery();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
            finally
            {
                AccessConnection.Close();
            }
            Sqlstmt1 = "ALTER TABLE PTP Add Column PART_NUMBER Text(50)";
            Sqlstmt2 = "UPDATE PTP SET  PART_NUMBER = [PART NUMBER]";
            Sqlstmt3 = "Alter table PTP drop column [PART NUMBER]";

            Sqlstmt4 = "ALTER TABLE PTP Add Column WIRE_NUMBER Text(50)";
            Sqlstmt5 = "UPDATE PTP SET WIRE_NUMBER = [WIRE NUMBER]";
            Sqlstmt6 = "Alter table PTP drop column [WIRE NUMBER]";

            Sqlstmt7 = "ALTER TABLE MPRS Add Column FR0M Text(50)";
            Sqlstmt8 = "UPDATE MPRS SET FR0M = [FROM]";
            Sqlstmt9 = "Alter table MPRS drop column [FROM]";

            Sqlstmt10 = "ALTER TABLE PTP Add Column WIRE_CABLE_CD Text(50)";
            Sqlstmt11 = "UPDATE PTP SET WIRE_CABLE_CD = [WIRE CABLE CD]";
            Sqlstmt12 = "Alter table PTP drop column [WIRE CABLE CD]";

            string Sqlstmt41 = "ALTER TABLE PTP Add Column WIRE_END_CD Text(50)";
            string Sqlstmt51 = "UPDATE PTP SET WIRE_END_CD = [WIRE END CD]";
            string Sqlstmt61 = "Alter table PTP drop column [WIRE END CD]";

            string Sqlstmt71 = "ALTER TABLE PTP Add Column WIRE_END_REF Text(50)";
            string Sqlstmt81 = "UPDATE PTP SET WIRE_END_REF = [WIRE END REF]";
            string Sqlstmt91 = "Alter table PTP drop column [WIRE END REF]";

            string Sqlstmt101 = "ALTER TABLE PTP Add Column WIRE_END_PIN Text(50)";
            string Sqlstmt111 = "UPDATE PTP SET WIRE_END_PIN = [WIRE END PIN]";
            string Sqlstmt121 = "Alter table PTP drop column [WIRE END PIN]";

            string Sqlstmt1011 = "ALTER TABLE PTP Add Column WIRE_END_PN Text(50)";
            string Sqlstmt1111 = "UPDATE PTP SET WIRE_END_PN = [WIRE END PN]";
            string Sqlstmt1211 = "Alter table PTP drop column [WIRE END PN]";

            string Sqlstmt411 = "ALTER TABLE PTP Add Column WIRE_LEN_MEAS Text(50)";
            string Sqlstmt511 = "UPDATE PTP SET WIRE_LEN_MEAS = [WIRE LEN MEAS]";
            string Sqlstmt611 = "Alter table PTP drop column [WIRE LEN MEAS]";

            string Sqlstmt711 = "ALTER TABLE PTP Add Column WIRE_SPEC_GAGE Text(50)";
            string Sqlstmt811 = "UPDATE PTP SET WIRE_SPEC_GAGE = [WIRE SPEC GAGE]";
            string Sqlstmt911 = "Alter table PTP drop column [WIRE SPEC GAGE]";

            try
            {
                AccessConnection.Open();
                trans = AccessConnection.BeginTransaction();
                try
                {
                    System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand(Sqlstmt1, AccessConnection);
                    AccessCommand.Transaction = trans;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt2;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt3;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt4;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt5;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt6;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt7;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt8;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt9;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt10;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt11;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt12;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt41;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt51;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt61;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt71;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt81;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt91;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt101;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt1011;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt1111;
                    AccessCommand.ExecuteNonQuery();

                    AccessCommand.CommandText = Sqlstmt111;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt121;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt1211;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt411;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt511;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt611;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt711;
                    AccessCommand.ExecuteNonQuery();

                    AccessCommand.CommandText = Sqlstmt811;
                    AccessCommand.ExecuteNonQuery();
                    AccessCommand.CommandText = Sqlstmt911;
                    AccessCommand.ExecuteNonQuery();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
            finally
            {
                AccessConnection.Close();
            }


            //DAO.DBEngine.SetOption(dbmaxlocksperfile, 250000)




            System.Data.OleDb.OleDbConnection AccessConn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "\\Omanmain.mdb");

            AccessConn.Open();


            //Cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & NAMF

            ADOX.Catalog ADOXCatalog = new ADOX.Catalog();
            // Dim ADOConnection As New ADODB.Connection

            //  ADOXCatalog.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            //"Data Source=" & NAMF & _
            //"Jet OLEDB:Engine Type=5;"

            AccessConnection.Open();
            //ADOXCatalog.ActiveConnection = AccessConnection

            //ADOXCatalog.Tables("MPRS").Columns("PART NUMBER").Name = "PART_NUMBER"
            //ADOXCatalog.Tables("PTP").Columns("Col1").Name = "NewColumnName"
            //ADOXCatalog.Tables("PTP").Columns("Col1").Name = "NewColumnName"
            //ADOXCatalog.Tables("PTP").Columns("Col1").Name = "NewColumnName"

            //ADOXCatalog.ActiveConnection.Close()
            //ADOXCatalog.ActiveConnection = Nothing
            System.Data.OleDb.OleDbCommand AccessCommand2 = new System.Data.OleDb.OleDbCommand("DELETE * FROM MPRS", AccessConn);
            AccessCommand2.ExecuteNonQuery();
            AccessCommand2.CommandText = "INSERT INTO [MPRS] SELECT * FROM [MS Access;DATABASE=" + Module1.newModule.NAMF + "].[MPRS]";
            AccessCommand2.ExecuteNonQuery();
            System.Data.OleDb.OleDbCommand AccessCommand21 = new System.Data.OleDb.OleDbCommand("DELETE * FROM CBE", AccessConn);
            AccessCommand21.ExecuteNonQuery();
            AccessCommand21.CommandText = "INSERT INTO [CBE] SELECT * FROM [MS Access;DATABASE=" + Module1.newModule.NAMF + "].[CBE]";
            AccessCommand21.ExecuteNonQuery();
            System.Data.OleDb.OleDbCommand AccessCommand211 = new System.Data.OleDb.OleDbCommand("DELETE * FROM PTP", AccessConn);
            AccessCommand211.ExecuteNonQuery();
            AccessCommand211.CommandText = "INSERT INTO [PTP] SELECT * FROM [MS Access;DATABASE=" + Module1.newModule.NAMF + "].[PTP]";
            AccessCommand211.ExecuteNonQuery();
            AccessConn.Close();
            DataSet ds = new DataSet();
            clsData dc = new clsData();
            DataSet set3 = new DataSet();
            clsData data3 = new clsData();
            DataSet dghf = new DataSet();
            dghf = dc.getData("SELECT * FROM PDFWIRE1");
            string wspecOld;
            string wspecNew;
            for (int HJ = 0; HJ <= dghf.Tables[0].Rows.Count - 1; HJ++)
            {

                wspecOld = Conversions.ToString(dghf.Tables[0].Rows[HJ]["wspecOld"]);
                wspecNew = Conversions.ToString(dghf.Tables[0].Rows[HJ]["wspcNew"]);
                dc.ExecuteSQL("UPDATE PTP SET WIRE_SPEC_GAGE = '" + wspecNew + "' WHERE WIRE_SPEC_GAGE='" + wspecOld + "'");
            }
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PN = 'M39029/101-553' WHERE WIRE_END_PN ='M39029/22-192'");


            dc.ExecuteSQL("UPDATE CBE SET PTNUMBER = 'M39029/101-553' WHERE PTNUMBER ='M39029/22-192'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PN = 'M39029/101-554' WHERE WIRE_END_PN ='M39029/22-193'");


            dc.ExecuteSQL("UPDATE CBE SET PTNUMBER = 'M39029/101-554' WHERE PTNUMBER ='M39029/22-193'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = '-' WHERE WIRE_END_PIN IS NULL");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'HO' WHERE WIRE_END_PIN ='H-O'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'LO' WHERE WIRE_END_PIN ='L-O'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'HO' WHERE WIRE_END_PIN ='H-0'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'LO' WHERE WIRE_END_PIN ='L-0'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'HO' WHERE WIRE_END_PIN ='H0'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'LO' WHERE WIRE_END_PIN ='L0'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'HI' WHERE WIRE_END_PIN ='H-I'");
            dc.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN = 'LI' WHERE WIRE_END_PIN ='L-I'");
            ds = dc.getData(" select distinct ptnumber as part from cbe");
            string par;
            try
            {
                ToolStripProgressBar spr1 = new ToolStripProgressBar();
                for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                {
                    spr1.Maximum = ds.Tables[0].Rows.Count;
                    spr1.Value = i;
                    spr1.ProgressBar.Refresh();
                    par = Conversions.ToString(ds.Tables[0].Rows[i]["part"]);
                    set3 = data3.getData(("SELECT * FROM tblObsolete WHERE PARTNUMBER ='" + par + "'"));
                    if ((set3.Tables[0].Rows.Count != 0))
                    {
                        string str3 = Conversions.ToString(set3.Tables[0].Rows[0][0]);
                        set3 = data3.getData(("SELECT * FROM TBLCURRENT WHERE hardwarecode ='" + str3 + "'"));
                        if ((set3.Tables[0].Rows.Count != 0))
                        {
                            string str31 = Conversions.ToString(set3.Tables[0].Rows[0][1]);
                            dc.ExecuteSQL("update cbe set ptnumber ='" + str31 + "' where ptnumber ='" + par + "'");
                            dc.ExecuteSQL("update ptp set WIRE_END_PN ='" + str31 + "' where WIRE_END_PN ='" + par + "'");
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
            XtraMessageBox.Show("Update MPRS data completed");
            //Dim dc As New clsData
            //Dim wait As New frmWait
            //Dim dialog As New OpenFileDialog
            //Dim data As New clsData
            //Me.Enabled = False
            //'Control.CheckForIllegalCrossThreadCalls(False)
            //Dim nAMF As String = Module1.NAMF
            //frmWait.BringToFront()
            //frmWait.FormBorderStyle = FormBorderStyle.Fixed3D
            //frmWait.TransparencyKey = (Color.Aqua)
            //frmWait.StartPosition = (1)
            //frmWait.Width = 400
            //frmWait.Height = 100
            //frmWait.Show()
            //frmWait.ShowInTaskbar = (True)
            //If nAMF.EndsWith(".mdb") Then
            //    Dim num As Integer
            //    Dim row2 As DataRow
            //    Dim str4 As String
            //    Dim str6 As String
            //    Dim enumerator As IEnumerator
            //    Dim enumerator2 As IEnumerator
            //    Dim enumerator3 As IEnumerator
            //    Dim data2 As New clsData
            //    Dim ni As String = nAMF
            //    isCrunch = True
            //    newconn = nAMF
            //    Dim set2 As DataSet = data.getData("select *  from CBE")
            //    isCrunch = False
            //    set2.Tables.Item(0).TableName = "CBE"
            //    set2.Tables.Item(0).Columns.Item(1).ColumnName = "DWG_DASH"
            //    set2.Tables.Item(0).Columns.Item(4).ColumnName = "REF_DES"
            //    set2.Tables.Item(0).Columns.Item(5).ColumnName = "PTNUMBER"
            //    set2.Tables.Item(0).Columns.Item(6).ColumnName = "REFDESENDPT"
            //    set2.Tables.Item("CBE").Columns.Remove("ID")
            //    Application.DoEvents()
            //    Application.DoEvents()
            //    Dim num5 As Integer = (set2.Tables.Item(0).Rows.Count - 1)
            //    num = 0
            //    Do While (num <= num5)
            //        frmWait.Text = "UPDATING MPRS."
            //        frmWait.LabelControl2.Visible = True
            //        frmWait.ProgressBarControl1.Visible = True
            //        frmWait.ProgressBarControl1.Properties.Minimum = 1
            //        frmWait.ProgressBarControl1.Properties.Maximum = set2.Tables.Item(0).Rows.Count
            //        frmWait.ProgressBarControl1.EditValue = (num + 1)
            //        frmWait.ProgressBarControl1.Update()
            //        frmWait.LabelControl2.Text = ("Checking CBE records " & Conversions.ToString(CInt((num + 1))) & " from " & Conversions.ToString(set2.Tables.Item(0).Rows.Count))
            //        frmWait.LabelControl2.Refresh()
            //        frmWait.Refresh()
            //        set2.Tables.Item("CBE").Rows.Item(num).SetAdded()
            //        num += 1
            //    Loop
            //    Try
            //        dc.ExecuteSQL("DELETE * FROM CBE")
            //    Catch exception1 As Exception

            //        Dim exception As Exception = exception1

            //    End Try
            //    Try
            //        enumerator = set2.Tables.Item(0).Rows.GetEnumerator
            //        Do While enumerator.MoveNext
            //            Dim current As DataRow = DirectCast(enumerator.Current, DataRow)
            //            Me.dsCrunch.Tables.Item("CBE").ImportRow(current)
            //        Loop
            //    Finally
            //        If TypeOf enumerator Is IDisposable Then
            //            TryCast(enumerator, IDisposable).Dispose()
            //        End If
            //    End Try
            //    Dim set3 As New DataSet
            //    Dim data3 As New clsData
            //    Dim source As DataRow() = Me.dsCrunch.Tables.Item("cbe").[Select]("PTNUMBER <> ''")
            //    Dim num6 As Integer = (source.Count - 1)
            //    num = 0
            //    Do While (num <= num6)
            //        row2 = source(num)
            //        str6 = Conversions.ToString(Interaction.IIf((row2.Item(4) Is DBNull.Value), "-", RuntimeHelpers.GetObjectValue(row2.Item(4))))
            //        frmWait.ProgressBarControl1.Properties.Minimum = 1
            //        frmWait.ProgressBarControl1.Properties.Maximum = (source.Count - 1)
            //        frmWait.ProgressBarControl1.EditValue = (num + 1)
            //        frmWait.ProgressBarControl1.Update()
            //        frmWait.LabelControl2.Text = ("Updating CBE RECORD " & Conversions.ToString(CInt((num + 1))) & " from " & Conversions.ToString(source.Count))
            //        frmWait.LabelControl2.Refresh()
            //        frmWait.Refresh()
            //        set3 = data3.getData(("SELECT * FROM tblObsolete WHERE PARTNUMBER ='" & str6 & "'"))
            //        If (set3.Tables.Item(0).Rows.Count <> 0) Then
            //            Dim str3 As String = Conversions.ToString(set3.Tables.Item(0).Rows.Item(0).Item(0))
            //            set3 = data3.getData(("SELECT * FROM TBLCURRENT WHERE hardwarecode ='" & str3 & "'"))
            //            If (set3.Tables.Item(0).Rows.Count <> 0) Then
            //                str4 = Conversions.ToString(Interaction.IIf((set3.Tables.Item(0).Rows.Item(0).Item(1) Is DBNull.Value), str6, RuntimeHelpers.GetObjectValue(set3.Tables.Item(0).Rows.Item(0).Item(1))))
            //                row2.Item(4) = str4
            //            End If
            //        End If
            //        num += 1
            //    Loop
            //    Dim count As Integer = set2.Tables.Item(0).Rows.Count
            //    Try
            //        Me.dsCrunch.GetChanges()
            //        frmWait.LabelControl2.Text = " SAVING PLEASE WAIT...."
            //        frmWait.Refresh()
            //        Application.DoEvents()
            //        Me.updatethread = New Thread(AddressOf CBEUPDATE)
            //        Me.updatethread.IsBackground = True
            //        Me.updatethread.Name = "UpdateThread"
            //        Me.updatethread.Start()
            //        Module1.ISRUNN2 = True
            //    Catch exception8 As Exception
            //        ProjectData.SetProjectError(exception8)
            //        Dim exception2 As Exception = exception8
            //        ProjectData.ClearProjectError()
            //    End Try
            //    isCrunch = True
            //    newconn = nAMF
            //    set2 = data.getData("select *  from PTP")
            //    isCrunch = False
            //    set2.Tables.Item(0).TableName = "PTP"
            //    set2.Tables.Item(0).Columns.Item(1).ColumnName = "PART_NUMBER"
            //    set2.Tables.Item(0).Columns.Item(4).ColumnName = "WIRE_NUMBER"
            //    set2.Tables.Item(0).Columns.Item(5).ColumnName = "WIRE_CABLE_CD"
            //    set2.Tables.Item(0).Columns.Item(6).ColumnName = "WIRE_END_CD"
            //    set2.Tables.Item(0).Columns.Item(7).ColumnName = "WIRE_END_REF"
            //    set2.Tables.Item(0).Columns.Item(8).ColumnName = "WIRE_END_PIN"
            //    set2.Tables.Item(0).Columns.Item(9).ColumnName = "WIRE_END_PN"
            //    set2.Tables.Item(0).Columns.Item(10).ColumnName = "WIRE_LEN_MEAS"
            //    set2.Tables.Item(0).Columns.Item(11).ColumnName = "WIRE_SPEC_GAGE"
            //    set2.Tables.Item(0).Columns.Remove("ID")
            //    Dim num7 As Integer = (set2.Tables.Item(0).Rows.Count - 1)
            //    num = 0
            //    Do While (num <= num7)
            //        frmWait.ProgressBarControl1.Properties.Minimum = 1
            //        frmWait.ProgressBarControl1.Properties.Maximum = set2.Tables.Item(0).Rows.Count
            //        frmWait.ProgressBarControl1.EditValue = (num + 1)
            //        frmWait.ProgressBarControl1.Update()
            //        frmWait.LabelControl2.Text = ("CHECKING PTP RECORD " & Conversions.ToString(CInt((num + 1))) & " from " & Conversions.ToString(set2.Tables.Item(0).Rows.Count))
            //        frmWait.LabelControl2.Refresh()
            //        frmWait.Refresh()
            //        set2.Tables.Item("PTP").Rows.Item(num).SetAdded()
            //        num += 1
            //    Loop
            //    Try
            //        dc.ExecuteSQL("DELETE * FROM PTP")
            //    Catch exception9 As Exception
            //        ProjectData.SetProjectError(exception9)
            //        Dim exception3 As Exception = exception9
            //        ProjectData.ClearProjectError()
            //    End Try
            //    Try
            //        enumerator2 = set2.Tables.Item(0).Rows.GetEnumerator
            //        Do While enumerator2.MoveNext
            //            Dim row As DataRow = DirectCast(enumerator2.Current, DataRow)
            //            frmWait.ProgressBarControl1.Properties.Minimum = 0
            //            frmWait.ProgressBarControl1.Properties.Maximum = set2.Tables.Item(0).Rows.Count
            //            frmWait.ProgressBarControl1.EditValue = (num + 1)
            //            frmWait.ProgressBarControl1.Update()
            //            frmWait.LabelControl2.Text = "Updating PTP RECORDS ...."
            //            frmWait.LabelControl2.Refresh()
            //            frmWait.Refresh()
            //            Me.dsCrunch.Tables.Item("PTP").ImportRow(row)
            //        Loop
            //    Finally
            //        If TypeOf enumerator2 Is IDisposable Then
            //            TryCast(enumerator2, IDisposable).Dispose()
            //        End If
            //    End Try
            //    source = Me.dsCrunch.Tables.Item("ptp").[Select]("WIRE_END_CD <> ''")
            //    Dim num8 As Integer = (source.Count - 1)
            //    num = 0
            //    Do While (num <= num8)
            //        row2 = source(num)
            //        str6 = Conversions.ToString(Interaction.IIf((row2.Item(8) Is DBNull.Value), "-", RuntimeHelpers.GetObjectValue(row2.Item(8))))
            //        frmWait.ProgressBarControl1.Properties.Minimum = 1
            //        frmWait.ProgressBarControl1.Properties.Maximum = (source.Count - 1)
            //        frmWait.ProgressBarControl1.EditValue = (num + 1)
            //        frmWait.ProgressBarControl1.Update()
            //        frmWait.LabelControl2.Text = ("Updating PTP RECORD " & Conversions.ToString(CInt((num + 1))) & " from " & Conversions.ToString(CInt((source.Count - 1))))
            //        frmWait.LabelControl2.Refresh()
            //        frmWait.Refresh()
            //        set3 = data3.getData(("SELECT * FROM tblObsolete WHERE PARTNUMBER ='" & str6 & "'"))
            //        If (set3.Tables.Item(0).Rows.Count <> 0) Then
            //            set3 = data3.getData(("SELECT * FROM TBLCURRENT WHERE hardwarecode ='" & Conversions.ToString(set3.Tables.Item(0).Rows.Item(0).Item(0)) & "'"))
            //            If (set3.Tables.Item(0).Rows.Count <> 0) Then
            //                str4 = Conversions.ToString(Interaction.IIf((set3.Tables.Item(0).Rows.Item(0).Item(1) Is DBNull.Value), str6, RuntimeHelpers.GetObjectValue(set3.Tables.Item(0).Rows.Item(0).Item(1))))
            //                row2.Item(8) = str4
            //            End If
            //        End If
            //        num += 1
            //    Loop
            //    Try
            //        Me.updatethread = New Thread(AddressOf PTPUPDATE)
            //        Me.updatethread.IsBackground = True
            //        Me.updatethread.Name = "UpdateThread"
            //        Me.updatethread.Start()
            //        Module1.ISRUNN = True
            //    Catch exception10 As Exception

            //    End Try
            //    isCrunch = True
            //    newconn = nAMF
            //    set2 = data.getData("select *  from MPRS")
            //    isCrunch = False
            //    frmWait.Text = "UPDATING MPRS."
            //    frmWait.LabelControl2.Visible = True
            //    frmWait.ProgressBarControl1.Visible = True
            //    frmWait.ProgressBarControl1.Properties.Minimum = 1
            //    frmWait.ProgressBarControl1.Properties.Maximum = set2.Tables.Item(0).Rows.Count
            //    frmWait.ProgressBarControl1.EditValue = (num + 1)
            //    frmWait.ProgressBarControl1.Update()
            //    frmWait.LabelControl2.Text = ("Updating MPRS RECORD " & Conversions.ToString(CInt((num + 1))) & " from " & Conversions.ToString(CInt((set2.Tables.Item(0).Rows.Count - 1))))
            //    frmWait.LabelControl2.Refresh()
            //    frmWait.Refresh()
            //    set2.Tables.Item(0).TableName = "MPRS"
            //    set2.Tables.Item(0).Columns.Item(4).ColumnName = "PART_NUMBER"
            //    set2.Tables.Item(0).Columns.Item(13).ColumnName = "DWG_ZONE"
            //    set2.Tables.Item(0).Columns.Item(7).ColumnName = "FR0M"
            //    set2.Tables.Item(0).Columns.Remove("ID")
            //    set2.Tables.Item(0).Columns.Remove("UPDATE")
            //    Dim num9 As Integer = (set2.Tables.Item(0).Rows.Count - 1)
            //    num = 0
            //    Do While (num <= num9)
            //        frmWait.ProgressBarControl1.Properties.Minimum = 1
            //        frmWait.ProgressBarControl1.Properties.Maximum = set2.Tables.Item(0).Rows.Count
            //        frmWait.ProgressBarControl1.EditValue = (num + 1)
            //        frmWait.ProgressBarControl1.Update()
            //        frmWait.LabelControl2.Text = ("Updating MPRS RECORD " & Conversions.ToString(CInt((num + 1))) & " from " & Conversions.ToString(CInt((set2.Tables.Item(0).Rows.Count - 1))))
            //        frmWait.LabelControl2.Refresh()
            //        frmWait.Refresh()
            //        set2.Tables.Item("MPRS").Rows.Item(num).SetAdded()
            //        num += 1
            //    Loop
            //    Try
            //        dc.ExecuteSQL("DELETE * FROM MPRS")
            //    Catch exception11 As Exception
            //        ProjectData.SetProjectError(exception11)
            //        Dim exception5 As Exception = exception11
            //        ProjectData.ClearProjectError()
            //    End Try
            //    Try
            //        enumerator3 = set2.Tables.Item(0).Rows.GetEnumerator
            //        Do While enumerator3.MoveNext
            //            Dim row5 As DataRow = DirectCast(enumerator3.Current, DataRow)
            //            Try
            //                Me.dsCrunch.Tables.Item("MPRS").ImportRow(row5)
            //            Catch exception12 As Exception
            //                ProjectData.SetProjectError(exception12)
            //                Dim exception6 As Exception = exception12
            //                ProjectData.ClearProjectError()
            //            End Try
            //        Loop
            //    Finally
            //        If TypeOf enumerator3 Is IDisposable Then
            //            TryCast(enumerator3, IDisposable).Dispose()
            //        End If
            //    End Try
            //    Try
            //        frmWait.LabelControl2.Text = " Saving data please wait...."
            //        frmWait.Refresh()
            //        Me.daMPRS.Update(Me.dsCrunch, "MPRS")
            //    Catch exception13 As Exception
            //        ProjectData.SetProjectError(exception13)
            //        Dim exception7 As Exception = exception13
            //        ProjectData.ClearProjectError()
            //    End Try
            //End If
            //frmWait.ProgressBarControl1.Visible = False
            //frmWait.Mr2.Visible = True
            //Do
            //    Application.DoEvents()
            //Loop While (Module1.ISRUNN OrElse Module1.ISRUNN2)
            //frmWait.Mr2.Visible = False
            //frmWait.LabelControl2.Text = "DONE!"
            //frmWait.Refresh()
            //frmWait.Close()
            //wait.Close()
            //Me.Enabled = True
            Module1.newModule.ISRUNN = false;

        }
        private void FillByToolStripButton_Click(System.Object sender, System.EventArgs e)
        {
            //Try
            //    Me.TblDwgsTableAdapter1.FillBy(Me.DsMain.tblDwgs)
            //Catch ex As System.Exception
            //    System.Windows.Forms.XtraMessageBox.Show(ex.Message)
            //End Try

        }

        private void FillProgram()
        {


            ImageComboBoxItem itm;
            clsData cls = new clsData();            
            DataSet ds;
            int i;
            int program;

            //Retrieve programs

            ds = cls.getData("select * from TBLGENERAL order by genplannumber");

            // Populate combo box
            //9:
            program = 0; // BJR
            if (ds.Tables.Count != 0) // BJR
            {
                program = ds.Tables[0].Rows.Count;
            }


            cmbCards.Properties.Items.Clear();
            for (i = 0; i <= program - 1; i++)
            {
                itm = new ImageComboBoxItem();
                itm.Value = 0; // BJR
                itm.Description = ""; // BJR
                if (ds.Tables.Count != 0) // BJR
                {
                    itm.Value = ds.Tables[0].Rows[i]["genPlannumber"];
                    itm.Description = Conversions.ToString(ds.Tables[0].Rows[i]["genPlid"]);
                }

                cmbCards.Properties.Items.Add(itm);
                cmbCards.SelectedIndex = 0;
                //cmbCards.Enabled = False
            }
            frmMain.start.cmbProgram.Text = "Oman";
            frmMain.start.txtCountry.Text = "Oman";

            //Dispose objects
            cls = null;
            ds.Dispose();
            ds = null;
        }

        private void FillCountryTail()
        {


            ImageComboBoxItem itm;
            clsData vlt = new clsData();

            DataSet ds;
            int i;
            int Vlaves;

            //Retrieve programs

            ds = vlt.getData("select * from tblTail order by tlSerial");

            //Populate combo box
            Vlaves = 0; // BJR
            if (ds.Tables.Count != 0) // BJR
            {
                Vlaves = ds.Tables[0].Rows.Count;
            }

            for (i = 0; i <= Vlaves - 1; i++)
            {
                itm = new ImageComboBoxItem();
                itm.Value = 0; // BJR
                itm.Description = ""; // BJR
                if (ds.Tables.Count != 0) // BJR
                {
                    itm.Value = ds.Tables[0].Rows[i]["tlSerial"];
                    itm.Description = Conversions.ToString(ds.Tables[0].Rows[i]["tlNumber"]);
                }
                //  cmbCountry.Properties.Items.Add(itm)
            }

            //Dispose objects
            vlt = null;
            ds.Dispose();
            ds = null;
        }
        private void FillCountry()
        {


            ImageComboBoxItem itm;
            clsData vlt = new clsData();

            DataSet ds;
            int i;
            int Vlaves;

            //Retrieve programs

            ds = vlt.getData("select * from tblCountry order by country");

            //Populate combo box
            Vlaves = ds.Tables[0].Rows.Count;
            for (i = 0; i <= Vlaves - 1; i++)
            {
                itm = new ImageComboBoxItem();
                itm.Value = ds.Tables[0].Rows[i]["ID"];
                itm.Description = Conversions.ToString(ds.Tables[0].Rows[i]["COUNTRY"]);
                //       frmProgram.cmbCountry.Properties.Items.Add(itm)
            }

            //Dispose objects
            vlt = null;
            ds.Dispose();
            ds = null;
        }

        private void cmbProgram_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {

        }

        private void cmbProgram_SelectedIndexChanged1(object sender, System.EventArgs e)
        {
            FillProgram();
            DialogResult ans;
            clsData dc = new clsData();
            DataSet ds = new DataSet();

            //cmbthing2 = cmbProgram.Text
            //cmbthing = cmbProgram.EditValue

            if (Module1.newModule.cmbthing == "1111")
            {
                ans = XtraMessageBox.Show("Add new Program ?", "ECN", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (ans == DialogResult.No)
                {
                    //Exit Sub
                }
                else
                {
                    //Dim frm As New frmProgram
                    //frm.MdiParent = Me
                    //frm.ShowDialog()
                    //FillProgram()


                }

            }
            else
            {





                if (Module1.newModule.cmbthing == "2222")
                {


                }
                else
                {
                    ds = dc.getData("SELECT * FROM tblEcn WHERE RCN LIKE '" + Module1.newModule.cmbthing + "%'");
                    Module1.newModule.ECP = Module1.newModule.cmbthing;
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        XtraMessageBox.Show("No Data Update ECN crunch run Or select a Program!");


                    }
                    frmCrunch.newfrmCrunch1.GridControl1.DataSource = ds.Tables[0];
                    //frmCrunch.GridView1.Columns("ProgEcnId").Visible = False
                    frmCrunch.newfrmCrunch1.GridView1.Columns["FIELD"].Visible = false;
                    //fill Country

                    ds = dc.getData("SELECT Country FROM tblProgram WHERE DESCRIPTION = '" + Module1.newModule.cmbthing2 + "'");
                    Module1.newModule.Country = Conversions.ToString(ds.Tables[0].Rows[0]["Country"]);

                    txtCountry.Text = Module1.newModule.Country;
                    frmCrunch.newfrmCrunch1.MdiParent = this;
                    frmCrunch.newfrmCrunch1.Show();
                }
            }

        }

        private void  // ERROR: Handles clauses are not supported in C#
    NavBarItem15_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            frmEfec.newfrmEfec1.MdiParent = this;
            frmEfec.newfrmEfec1.Show();
        }

        private void chc1_CausesValidationChanged(object sender, System.EventArgs e)
        {

        }

        private void  // ERROR: Handles clauses are not supported in C#
    txtSearch_Click(System.Object sender, System.EventArgs e)
        {

            clsData dc = new clsData();
            DataSet ds = new DataSet();
            DataSet ds2 = new DataSet();
            frmSearch frm = new frmSearch();
            ds = dc.getData("select genPlId,genTypeVer,genDescription,genPlannumber,prtPartNumberDoc,prtDescription from tblGeneral,tblAssembly where prtPlId =prtPlId and genPlId=prtPlId  and prtPartNumberDoc LIKE '" + txtSearch.Text.Trim() + "%'");

            //ds2 = dc.getData("select genPlId,genTypeVer,genDescription,genPlannumber,partnumber,DESCRIPTION from tblGeneral,tblrefdescomp where REFCOMPPLID =REFCOMPPLID and genPlId=REFCOMPPLID  and PARTNUMBER LIKE '" & txtSearch.Text.Trim & "%'")

            //ds = dc.getData("select genPlId,genTypeVer,genDescription,genPlannumber,prtPartNumberDoc,prtDescription from tblGeneral,tblAssembly where prtPlId =prtPlId and genPlId=prtPlId  and ((prtTypeVer ='" & TypeVer & "'and " & effEnds & " between prtFrom and prtThru ) or ( prtTypeVer = '999' and prtThru = 9999 ))and prtPartNumberDoc LIKE '" & txtSearch.Text.Trim & "%' and genPlId in([select] efPlId as genPlId from tblEffectivities where (efTypeVer ='" & TypeVer & "' and (" & effEnds & " between INT(efFrom ) and INT(efThru ) )) or ( efTypeVer = '999' and efThru like '999%' ))")

            ds2 = dc.getData("select genPlId,genTypeVer,genDescription,genPlannumber,partnumber,DESCRIPTION from tblGeneral,tblrefdescomp where REFCOMPPLID =REFCOMPPLID and genPlId=REFCOMPPLID  and PARTNUMBER LIKE '" + txtSearch.Text.Trim() + "%'");
            //Createadapter(dsdrawings, "tblAssembly", "prtPlId = '" & PlanNumber & "' and ((prtTypeVer ='" & TypeVer & "'and " & effEnds & " between prtFrom and prtThru ) or ( prtTypeVer = '999' and prtThru = 9999 ))", daAssemply)
            // Createadapter(dsElectrical, "tblAssembly", "prtPlId = '" & PlanNumber & "' and ((prtTypeVer ='" & TypeVer & "'and " & effEnds & " between prtFrom and prtThru ) or ( prtTypeVer = '999' and prtThru = 9999 ))", daAssemply)

            ds2.Tables[0].Columns[4].ColumnName = "prtPartNumberDoc";
            ds2.Tables[0].Columns[5].ColumnName = "prtDescription";
            ds.Merge(ds2);
            DataSet set3 = new DataSet();
            set3 = dc.getData(("select genPlId,genTypeVer,genDescription,genPlannumber,tlPartNumber,tlDescription from tblGeneral,tbltools where tlPlid =tlPlid and genPlId=tlPlid  and tlPartNumber LIKE '" + this.txtSearch.Text.Trim() + "%'"));
            set3.Tables[0].Columns[4].ColumnName = "prtPartNumberDoc";
            set3.Tables[0].Columns[5].ColumnName = "prtDescription";
            ds.Merge(set3);
            if (txtSearch.Text == "")
            {
                frm.Text = "External view search ";
            }
            else
            {
                frm.Text = "Results for '' " + txtSearch.Text + "''";
                frm.MdiParent = this;
            }

            frm.gridSearchResult.DataSource = ds.Tables[0];
            frm.GridView1.BestFitColumns();

            frm.Show();
            //'Dim dc As New clsData
            //'Dim ds As New DataSet
            //'Dim frm As New frmSearch


            //'ds = dc.getData("select * from tblGeneral,tblAssembly where genPlId =genPlId and prtPlId=genPlId and prtPartNumberDoc LIKE '" & txtSearch.Text.Trim & "%'")

            //'frm.MdiParent = Me
            //'frm.gridSearchResult.DataSource = ds.Tables(0)

            //'frm.Show()

        }

        private void txtSearch_Enter(object sender, System.EventArgs e) // ERROR: Handles clauses are not supported in C#
        {
            if (txtSearch.Text.Contains("Search")) // ERROR: Unknown binary operator Like //JMR -- fixed
            {
                txtSearch.Text = "";

            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton1_Click_1(System.Object sender, System.EventArgs e)
        {
            clsData dc = new clsData();
            DataSet ds = new DataSet();
            frmSearch frm = new frmSearch();


            ds = dc.getData("select * from tblGeneral,tblRefDesComp where genPlId =genPlId and REFCOMPPLID= genPlId  and PARTNUMBER like '%" + txtSearchE.Text.Trim() + "%'");

            frm.MdiParent = this;
            frm.gridSearchResult.DataSource = ds.Tables[0];

            frm.Show();
        }

        private void txtSearchE_Enter(object sender, System.EventArgs e)// ERROR: Handles clauses are not supported in C#
        {
            if (txtSearchE.Text.Contains("Search")) // ERROR: Unknown binary operator Like //JMR -- fixed
            {
                txtSearchE.Text = "";

            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    btnPtp_Click(System.Object sender, System.EventArgs e)
        {
            frmPtp frm = new frmPtp();
            DataSet dptp = new DataSet();
            clsData dcptp = new clsData();
            //dptp = dcptp.getData("select * from ptp")
            //frm.grdWireNo.DataSource = dptp.Tables(0)
            //Form F;     //JMR -- look at -- commented out because i put the declaration in the foreach parenthesis
            try
            {
                foreach (Form F in System.Windows.Forms.Application.OpenForms)
                {
                    if (F.Name == frm.Name)
                    {
                        //  F.Close()
                        F.Focus();
                        return;
                    }
                    else
                    {

                    }
                }

            }
            catch (Exception ex)
            {

            }
            frm.Show();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    btnCbe_Click(System.Object sender, System.EventArgs e)
        {
            frmCbe frm = new frmCbe();

            DataSet dcbe = new DataSet();
            clsData dccbe = new clsData();
            dcbe = dccbe.getData("select * from cbe");
            frm.grdWireNo.DataSource = dcbe.Tables[0];
            //Form F;        //JMR -- look at -- commented out because I put the declaration in the foreach parenthesis
            try
            {
                foreach (Form F in System.Windows.Forms.Application.OpenForms)
                {
                    if (F.Name == frm.Name)
                    {
                        //  F.Close()
                        F.Focus();
                        return;
                    }
                    else
                    {

                    }
                }

            }
            catch (Exception ex)
            {

            }
            frm.Show();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    btnMprs_Click(System.Object sender, System.EventArgs e)
        {
            frmMprs frm = new frmMprs();
            DataSet DMPRS = new DataSet();
            clsData dcMPRS = new clsData();
            DMPRS = dcMPRS.getData("select * from MPRS");
            frm.grdWireNo.DataSource = DMPRS.Tables[0];
            //Form F;     //JMR -- look at -- Commented out because I put the declaration in the foreach parenthesis
            try
            {
                foreach (Form F in System.Windows.Forms.Application.OpenForms)
                {
                    if (F.Name == frm.Name)
                    {
                        //  F.Close()
                        F.Focus();
                        return;
                    }
                    else
                    {

                    }
                }

            }
            catch (Exception ex)
            {

            }
            frm.Show();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton2_Click(System.Object sender, System.EventArgs e)
        {
            frmCardHarness frm = new frmCardHarness();
            if (Module1.newModule.oldharn == null)
            {
                MessageBox.Show("This option is available only when a card is opened", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                frm.Show();
            }

        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton3_Click(System.Object sender, System.EventArgs e)
        {
            frmCards FRM = new frmCards();
            if (1 == 2) // WTF BJR
            {
                XtraMessageBox.Show("Please select a TailNo first!", "ePlanViewerOman...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {

                FRM.Show();
            }

        }
        private static void CBEUPDATE()
        {
            //Module1.ISRUNN2 = True
            //Me.daCBE.Update(Me.dsCrunch, "CBE")
            //Module1.ISRUNN2 = False
        }

        private static void PTPUPDATE()
        {
            //frmWait.LabelControl2.Text = " SAVING PLEASE WAIT...."
            //frmWait.Refresh()
            //Module1.ISRUNN = True
            //Me.daPTP.Update(Me.dsCrunch, "PTP")
            //Module1.ISRUNN = False
        }





        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton5_Click(System.Object sender, System.EventArgs e)
        {

        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton6_Click(System.Object sender, System.EventArgs e)
        {
            //  ZipFiles()
            frmMKPL frm = new frmMKPL();
            frm.Show();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton7_Click(System.Object sender, System.EventArgs e)
        {
            if (frmDetail.newfrmDetail1.IsDisposed)
            {
                frmDetail.newfrmDetail1 = new frmDetail();
            }
            frmDetail.newfrmDetail1.Show();
            //Dim ans As DialogResult
            //ans = XtraMessageBox.Show("Are you sure?", "Fill END2", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            //If ans = Windows.Forms.DialogResult.No Then
            //    Exit Sub
            //End If
            //Dim DC As New clsData
            //Try
            //    Dim Sqlstmt1 As String = "ALTER TABLE tblwiresadd Add Column ROUTE Text(50)"
            //    DC.ExecuteSQL(Sqlstmt1)
            //Catch ex As Exception

            //End Try
            //Try
            //    Dim Sqlstmt1 As String = "ALTER TABLE tblwiresREMOVE Add Column ROUTE Text(50)"
            //    DC.ExecuteSQL(Sqlstmt1)
            //Catch ex As Exception

            //End Try

            //Dim DSROT As New DataSet
            //Dim DSCAD As New DataSet
            //DSCAD = DC.getData("SELECT * FROM TBLGENERAL WHERE genplannumber like '30%'")
            //For JK = 0 To DSCAD.Tables(0).Rows.Count - 1
            //    Me.spr1.Maximum = DSCAD.Tables(0).Rows.Count - 1
            //    Me.spr1.ProgressBar.Value = JK
            //    Me.spr1.ProgressBar.Refresh()
            //    Dim CARDid As String
            //    CARDid = DSCAD.Tables(0).Rows(JK).Item("genPlId")


            //    DSROT = DC.getData("SELECT * FROM TBLWIRESADD WHERE WIRESPLID ='" & CARDid & "' AND ROUTE IS NULL")
            //    For hj = 0 To DSROT.Tables(0).Rows.Count - 1
            //        Module1.wireno1 = DSROT.Tables(0).Rows(hj).Item("WIRENO")
            //        Module1.ACTION = DSROT.Tables(0).Rows(hj).Item("WIREACTID")
            //        Module1.end1 = DSROT.Tables(0).Rows(hj).Item("SREFDES")
            //        sql = String.Format("UPDATE TBLWIRESADD SET ROUTE ='{0}' where (WireNo = '{1}' and WIRESPlId = '{2}' and WIREACTID ='{3}' and SREFDES <> '{4}') ", New Object() {Module1.end1, Module1.wireno1, CARDid, Module1.ACTION, Module1.end1})
            //        DC.ExecuteSQL(sql)

            //    Next
            //    DSROT = DC.getData("SELECT * FROM TBLWIRESREMOVE WHERE WIRESPLID ='" & CARDid & "' AND ROUTE IS NULL")
            //    For hj = 0 To DSROT.Tables(0).Rows.Count - 1
            //        Module1.wireno1 = DSROT.Tables(0).Rows(hj).Item("WIRENO")
            //        Module1.ACTION = DSROT.Tables(0).Rows(hj).Item("WIREACTID")
            //        Module1.end1 = DSROT.Tables(0).Rows(hj).Item("SREFDES")
            //        sql = String.Format("UPDATE TBLWIRESREMOVE SET ROUTE ='{0}' where (WireNo = '{1}' and WIRESPlId = '{2}' and WIREACTID ='{3}' and SREFDES <> '{4}') ", New Object() {Module1.end1, Module1.wireno1, CARDid, Module1.ACTION, Module1.end1})
            //        DC.ExecuteSQL(sql)

            //    Next


            //Next
            //XtraMessageBox.Show("Process done!", "route", MessageBoxButtons.OK)
            //spr1.ProgressBar.Value = 0

        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton8_Click(System.Object sender, System.EventArgs e)
        {

            DataRow row;
            string str = "";//JMR -- nulled it
            string str4;
            int num;
            string str5;
            SaveFileDialog dialog = new SaveFileDialog();
            xrParts parts = new xrParts();
            DataSet aset = new DataSet();
            clsData data = new clsData();
            DataSet set2 = new DataSet();
            DataSet dataSet = new DataSet();
            DataSet set4 = new DataSet();
            DataSet ser45 = new DataSet();
            DataSet SETAS = new DataSet();
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            aset = data.getData(string.Concat(new string[] {
        "SELECT DISTINCT (bacWireNo),bacLength,WIRE_SPEC_GAGE FROM TBLCONT,PTP WHERE   bacPlId ='",
        this.PLRER,
        "' AND bacAction ='ADD' and bacWireno = WIRE_NUMBER and PART_NUMBER ='",
        this.GHARN,
        "'"
      }));
            DataRow[] source = aset.Tables[0].Select("bacLength ='9992'");
            int num14 = (source.Count() - 1);
            int i = 0;
            while ((i <= num14))
            {
                row = source[i];
                row[1] = "";
                row[2] = "";
                i += 1;
            }
            source = aset.Tables[0].Select("bacLength ='WIRE MARKER' and bacWireNo like '%SH%'");
            int num15 = (source.Count() - 1);
            int j = 0;
            while ((j <= num15))
            {
                row = source[j];
                row[2] = "";
                j += 1;
            }
            DataSet set6 = new DataSet();
            source = aset.Tables[0].Select("WIRE_SPEC_GAGE <>''");
            int num16 = (source.Count() - 1);
            int k = 0;
            while ((k <= num16))
            {
                row = source[k];
                set6 = data.getData(("SELECT * FROM PDFWIRE1 WHERE wspecOld ='" + Conversions.ToString(row[2]) + "'"));
                if ((set6.Tables[0].Rows.Count != 0))
                {
                    string str2 = Conversions.ToString(set6.Tables[0].Rows[0][1]);
                    row[2] = str2;
                }
                k += 1;
            }
            source = aset.Tables[0].Select("bacLength ='WIRE MARKER'");
            int num17 = (source.Count() - 1);
            int m = 0;
            while ((m <= num17))
            {
                row = source[m];
                row[2] = "";
                m += 1;
            }
            source = aset.Tables[0].Select("WIRE_SPEC_GAGE ='C4928-20'");
            int num18 = (source.Count() - 1);
            int n = 0;
            while ((n <= num18))
            {
                row = source[n];
                row[2] = "M22759/91-20-9";
                n += 1;
            }
            source = aset.Tables[0].Select("WIRE_SPEC_GAGE ='C4928-22'");
            int num19 = (source.Count() - 1);
            int num7 = 0;
            while ((num7 <= num19))
            {
                row = source[num7];
                row[2] = "M22759/91-22-9";
                num7 += 1;
            }
            source = aset.Tables[0].Select("WIRE_SPEC_GAGE ='C4928-24'");
            int num20 = (source.Count() - 1);
            int num8 = 0;
            while ((num8 <= num20))
            {
                row = source[num8];
                row[2] = "M22759/81-24-9";
                num8 += 1;
            }
            source = aset.Tables[0].Select("WIRE_SPEC_GAGE ='C4928-26'");
            int num21 = (source.Count() - 1);
            int num9 = 0;
            while ((num9 <= num21))
            {
                row = source[num9];
                row[2] = "C20805-26";
                num9 += 1;
            }
            ser45 = aset.Copy();
            ser45.AcceptChanges();
            parts.GridControl2.DataSource = aset.Tables[0];            
            set4 = data.getData("SELECT PARTNUMBER,DESCRIPTION,QTY,LOCATION FROM TBLREFDESCOMP WHERE 1 = 2");
            aset = data.getData(("SELECT distinct PARTNUMBER FROM TBLREFDESCOMP WHERE REFCOMPPLID ='" + this.PLRER + "' AND REFACTION ='ADD'"));
            int num22 = (aset.Tables[0].Rows.Count - 1);
            int num10 = 0;
            while ((num10 <= num22))
            {
                str4 = Conversions.ToString(aset.Tables[0].Rows[num10][0]);
                dataSet = data.getData(string.Concat(new string[] {
          "SELECT  PARTNUMBER,DESCRIPTION,QTY,LOCATION FROM TBLREFDESCOMP WHERE REFCOMPPLID ='",
          this.PLRER,
          "' and partnumber ='",
          str4,
          "' and qty <> 'REF' AND REFACTION ='ADD'"
        }));
                if ((dataSet.Tables[0].Rows.Count > 1))
                {
                    num = 0;
                    int num23 = (dataSet.Tables[0].Rows.Count - 1);
                    int num11 = 0;
                    while ((num11 <= num23))
                    {
                        if ((Conversions.ToString(dataSet.Tables[0].Rows[num11][2]) != "AR"))
                        {
                            if ((num11 == 0))
                            {
                                num = Conversions.ToInteger(Conversions.ToString(dataSet.Tables[0].Rows[num11][2]));
                                str = Conversions.ToString(dataSet.Tables[0].Rows[num11][3]);
                            }
                            else
                            {
                                str5 = Conversions.ToString(dataSet.Tables[0].Rows[num11][2]);

                                try
                                {
                                    num = (int)Math.Round((double)(num + Conversions.ToDouble(Conversions.ToString(dataSet.Tables[0].Rows[k][2]))));
                                    dataSet.Tables[0].Rows[0][2] = num;
                                }
                                catch (Exception ex)
                                {
                                    dataSet.Tables[0].Rows[0][2] = (dataSet.Tables[0].Rows[k][2]);
                                    XtraMessageBox.Show("Check QTY on parts list");
                                }
                                str = Conversions.ToString(Operators.AddObject(str, Operators.ConcatenateObject(", ", dataSet.Tables[0].Rows[num11][3])));
                                dataSet.Tables[0].Rows[num11].Delete();

                                dataSet.Tables[0].Rows[0][3] = str;
                            }
                        }
                        num11 += 1;
                    }
                }
                set4.Merge(dataSet);
                num10 += 1;
            }
            SETAS = data.getData("SELECT PARTNUMBER,DESCRIPTION as NOMENCLATURE,QTY,LOCATION FROM TBLREFDESCOMP WHERE 1 = 2");

            DataSet set3 = new DataSet();
            set3 = data.getData(("select distinct  prtPartNumberDoc from tblAssembly where prtAction ='ADD' and  prtPlId ='" + this.PLRER + "'"));
            int num24 = (set3.Tables[0].Rows.Count - 1);
            int num12 = 0;
            while ((num12 <= num24))
            {
                str4 = Conversions.ToString(set3.Tables[0].Rows[num12][0]);
                dataSet = data.getData(string.Concat(new string[] {
          "select prtPartNumberDoc,prtDescription,prtQty,prtFlag from tblAssembly where  prtPartNumberDoc ='",
          str4,
          "' and prtAction ='ADD' and  prtPlId ='",
          this.PLRER,
          "'"
        }));
                str = Conversions.ToString(dataSet.Tables[0].Rows[0][0]);
                if (((dataSet.Tables[0].Rows.Count > 1) && !LikeOperator.LikeString(str, "P5374-*", CompareMethod.Binary)))
                {
                    num = 0;
                    int num25 = (dataSet.Tables[0].Rows.Count - 1);
                    int num13 = 0;
                    while ((num13 <= num25))
                    {
                        if ((Conversions.ToString(dataSet.Tables[0].Rows[num13][2]) != "AR"))
                        {
                            if ((num13 == 0))
                            {
                                num = Conversions.ToInteger(Conversions.ToString(dataSet.Tables[0].Rows[num13][2]));
                                str = Conversions.ToString(dataSet.Tables[0].Rows[num13][3]);
                            }
                            else
                            {
                                str5 = Conversions.ToString(dataSet.Tables[0].Rows[num13][2]);
                                try
                                {
                                    num = (int)Math.Round((double)(num + Conversions.ToDouble(Conversions.ToString(dataSet.Tables[0].Rows[k][2]))));
                                    dataSet.Tables[0].Rows[0][2] = num;
                                }
                                catch (Exception ex)
                                {
                                    dataSet.Tables[0].Rows[0][2] = (dataSet.Tables[0].Rows[k][2]);
                                    XtraMessageBox.Show("Check QTY on parts list");
                                }
                                str = Conversions.ToString(Operators.AddObject(str, Operators.ConcatenateObject(", ", dataSet.Tables[0].Rows[num13][3])));
                                dataSet.Tables[0].Rows[num13].Delete();

                                dataSet.Tables[0].Rows[0][3] = str;
                            }
                        }
                        num13 += 1;
                    }
                }
                dataSet.Tables[0].Columns[0].ColumnName = "PARTNUMBER";
                dataSet.Tables[0].Columns[1].ColumnName = "NOMENCLATURE";
                dataSet.Tables[0].Columns[2].ColumnName = "QTY";
                dataSet.Tables[0].Columns[3].ColumnName = "LOCATION";
                SETAS.Merge(dataSet);
                num12 += 1;
            }
            SETAS.AcceptChanges();
            if (GHARN == "")
            {
                parts.LabelControl1.Text = ("MKPL FOR  " + CARDTypeVer + "/" + thirteen + ten + carddesc);
                parts.GridControl1.DataSource = set4.Tables[0];

            }
            else
            {
                parts.LabelControl1.Text = ("MKPL FOR " + this.carddesc);
                parts.GridControl1.DataSource = set4.Tables[0];

                parts.LabelControl1.Text = string.Concat(new string[] {
          "MKPL for ",
          this.GHARN.Substring(0, this.GHARN.IndexOf("-")),
          " from ",
          this.GHARNOLD.Substring(this.GHARNOLD.IndexOf("-")),
          " to ",
          this.GHARN.Substring(this.GHARN.IndexOf("-")),
          " ( LWA ",
          this.GHARN.Substring(0, this.GHARN.IndexOf("-")),
          "-",
          this.cardtbd,
          ")"
        });
            }
            ser45.Tables[0].Columns[0].ColumnName = "WIRE NUMBER";
            ser45.Tables[0].Columns[1].ColumnName = "ENG LENGTH";
            ser45.Tables[0].Columns["WIRE_SPEC_GAGE"].SetOrdinal(1);
            ser45.Tables[0].Columns["ENG LENGTH"].SetOrdinal(2);
            ser45.AcceptChanges();
            set4.AcceptChanges();


            if (cardnopl.StartsWith("50"))
            {
                isMKPL = true;
                ExportToExcel50(set4.Tables[0], ser45.Tables[0], ser45.Tables[0]);
            }
            else if (cardnopl.StartsWith("30"))
            {
                ExportToExcel30(SETAS.Tables[0], set4.Tables[0], ser45.Tables[0]);
            }
            else
            {
                try
                {
                    ExportToExcel(SETAS.Tables[0], set4.Tables[0], ser45.Tables[0]);

                }
                catch (Exception ex)
                {
                    MessageBox.Show("NO MKPL DATA");
                }
            }
            //ExportToExcel50(set4.Tables(0), ser45.Tables(0), ser45.Tables(0))
            //parts.ShowPreview()
        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton9_Click(System.Object sender, System.EventArgs e)
        {
            if (cardnopl.StartsWith("50"))
            {
                string str5;
                DataRow row;
                string str8;
                DataSet aset = new DataSet();
                DataSet set2 = new DataSet();
                clsData data2 = new clsData();
                xrBraidNO dno = new xrBraidNO();
                xrBraidGROUP dgroup = new xrBraidGROUP();
                bool flag = false;
                DataSet set78 = new DataSet();
                int index = this.GHARN.IndexOf("-");
                aset = data2.getData(("SELECT * FROM TBLREFDESCOMP WHERE REFCOMPPLID ='" + this.PLRER + "' AND REFACTION ='ADD'"));
                DataSet set3 = new DataSet();
                clsData data = new clsData();
                DataSet dataSet = new DataSet();
                set3 = data.getData("SELECT PARTNUMBER,DESCRIPTION,QTY,LOCATION FROM TBLREFDESCOMP WHERE 1 = 2");
                aset = data.getData(("SELECT distinct PARTNUMBER FROM TBLREFDESCOMP WHERE REFCOMPPLID ='" + this.PLRER + "' AND REFACTION ='ADD'"));
                int num22 = (aset.Tables[0].Rows.Count - 1);
                int i = 0;
                while ((i <= num22))
                {
                    string str11 = Conversions.ToString(aset.Tables[0].Rows[i][0]);
                    dataSet = data.getData(string.Concat(new string[] {
            "SELECT  PARTNUMBER,DESCRIPTION,QTY,LOCATION FROM TBLREFDESCOMP WHERE REFCOMPPLID ='",
            this.PLRER,
            "' and partnumber ='",
            str11,
            "' and qty <> 'REF' AND REFACTION ='ADD'"
          }));
                    if ((dataSet.Tables[0].Rows.Count > 1))
                    {
                        int num2 = 0;
                        int num23 = (dataSet.Tables[0].Rows.Count - 1);
                        int num4 = 0;
                        while ((num4 <= num23))
                        {
                            if ((Conversions.ToString(dataSet.Tables[0].Rows[num4][2]) != "AR"))
                            {
                                string str7 = "";//JMR -- nulled it;
                                if ((num4 == 0))
                                {
                                    num2 = Conversions.ToInteger(Conversions.ToString(dataSet.Tables[0].Rows[num4][2]));
                                    str7 = Conversions.ToString(dataSet.Tables[0].Rows[num4][3]);
                                }
                                else
                                {
                                    string str12 = Conversions.ToString(dataSet.Tables[0].Rows[num4][2]);
                                    num2 = (int)Math.Round((double)(num2 + Conversions.ToDouble(Conversions.ToString(dataSet.Tables[0].Rows[num4][2]))));
                                    str7 = Conversions.ToString(Operators.AddObject(str7, Operators.ConcatenateObject(", ", dataSet.Tables[0].Rows[num4][3])));
                                    dataSet.Tables[0].Rows[num4].Delete();
                                    dataSet.Tables[0].Rows[0][2] = num2;
                                    dataSet.Tables[0].Rows[0][3] = str7;
                                }
                            }
                            num4 += 1;
                        }
                    }
                    set3.Merge(dataSet);
                    i += 1;
                }
                set78 = set3.Copy();
                set78.AcceptChanges();
                dno.GridControl1.DataSource = set3.Tables[0];
                dgroup.GridControl1.DataSource = set3.Tables[0];
                aset = null;
                string str6 = "A";
                data2.ExecuteSQL(("UPDATE TBLCONT SET bacWireSpec ='',bacBraid ='' WHERE BACPLID ='" + this.PLRER + "'"));
                clsData data3 = new clsData();
                data3.ExecuteSQL(("UPDATE TBLCONT SET bacLength ='9992' WHERE bacWireNo LIKE '%SH%' AND bacPlId ='" + this.PLRER + "'"));


                DataRow ROQW;
                DataSet set6 = new DataSet();
                set6 = data2.getData(("SELECT * FROM TBLCONT WHERE (BACWIRENO  LIKE '%%') AND ((BACREFDES1 LIKE '%WT%') or (BACREFDES2 LIKE '%WT%') or (BACREFDES1 LIKE '%NEAR%') or (BACREFDES2 LIKE '%NEAR%')) AND BACPLID ='" + this.PLRER + "'"));
                int num24 = (set6.Tables[0].Rows.Count - 1);
                int j = 0;
                while ((j <= num24))
                {
                    string str = Conversions.ToString(set6.Tables[0].Rows[j][1]);
                    string str2 = Conversions.ToString(set6.Tables[0].Rows[j][5]);
                    string str3 = str;
                    string str4 = str2;
                    if (str.Contains("NEAR"))
                    {
                        str = str.Substring((str.IndexOf("(") + 5));
                        str = str.Substring(0, str.IndexOf(")")).Trim();
                        data3.ExecuteSQL(string.Concat(new string[] {
              "UPDATE TBLCONT SET BACREFDES1 ='",
              str,
              "' WHERE BACWIRENO LIKE '%-1' AND BACREFDES1 ='",
              str3,
              "' AND bacPlId ='",
              this.PLRER,
              "'"
            }));
                    }
                    else
                    {
                        if (str2.Contains("NEAR"))
                        {
                            str2 = str2.Substring((str2.IndexOf("(") + 5)).Trim();
                            str2 = str2.Substring(0, str2.IndexOf(")")).Trim();
                        }

                        data3.ExecuteSQL(string.Concat(new string[] {
              "UPDATE TBLCONT SET BACREFDES2 ='",
              str2,
              "' WHERE BACWIRENO LIKE '%-1' AND BACREFDES2 ='",
              str4,
              "' AND bacPlId ='",
              this.PLRER,
              "'"
            }));


                    }
                    j += 1;
                }

                //'

                aset = data2.getData(("SELECT * FROM TBLCONT WHERE  (BACPIN1 NOT LIKE '%S7%') AND (BACPIN2 NOT LIKE'%S7%')AND (BACWIRENO NOT LIKE'%WHT%') AND (BACWIRENO NOT LIKE'%BLK%') AND bacPlId ='" + this.PLRER + "' AND bacAction ='ADD' ORDER BY bacBraid,bacRefdes1,BACREFDES2,BACLENGTH "));
                int num25;
                int k;
                num25 = (aset.Tables[0].Rows.Count - 1);
                k = 0;
                while ((k <= num25))
                {
                    string str14;
                    string str15;
                    string str16 = "";//JMR -- nulled it
                    string str17 = "";//JMR -- nulled it
                    if ((k == 0))
                    {
                        str14 = Conversions.ToString(aset.Tables[0].Rows[k][1]);
                        str15 = Conversions.ToString(aset.Tables[0].Rows[k][5]);
                        str16 = str14;
                        str17 = str15;
                    }
                    else
                    {
                        str14 = Conversions.ToString(aset.Tables[0].Rows[k][1]);
                        str15 = Conversions.ToString(aset.Tables[0].Rows[k][5]);
                    }
                    if ((((str14 != str16) || (str15 != str17)) || (k == 0)))
                    {
                        string str13;
                        if ((k == 0))
                        {
                            set2 = data2.getData(string.Concat(new string[] {
                "select distinct(left(bacwireno,",
                Conversions.ToString(index),
                ")) from tblcont WHERE bacWireSpec ='' and baclength NOT IN('9992','WIRE MARKER') and BACREFDES1 ='",
                str14,
                "' AND BACREFDES2 ='",
                str15,
                "' AND BACPLID ='",
                this.PLRER,
                "'"
              }));
                            if (((set2.Tables[0].Rows.Count == 1) | (set2.Tables[0].Rows.Count == 0)))
                            {
                                try
                                {
                                    str13 = Conversions.ToString(set2.Tables[0].Rows[0][0]);
                                }
                                catch (Exception exception1)
                                {
                                    ProjectData.SetProjectError(exception1);
                                    Exception exception = exception1;
                                    ProjectData.ClearProjectError();
                                }
                                data2.ExecuteSQL(string.Concat(new string[] {
                  "UPDATE TBLCONT SET bacWireSpec ='",
                  str14,
                  " - ",
                  str15,
                  "' WHERE baclength NOT IN('9992','WIRE MARKER') and BACREFDES1 ='",
                  str14,
                  "' AND BACREFDES2 ='",
                  str15,
                  "' AND BACPLID ='",
                  this.PLRER,
                  "'"
                }));
                                data2.ExecuteSQL(string.Concat(new string[] {
                  "UPDATE TBLCONT SET bacBraid ='A' WHERE BACREFDES1 ='",
                  str14,
                  "' AND BACREFDES2 ='",
                  str15,
                  "' AND BACPLID ='",
                  this.PLRER,
                  "'"
                }));
                            }
                            else
                            {
                                data2.ExecuteSQL(string.Concat(new string[] {
                  "UPDATE TBLCONT SET bacWireSpec ='",
                  str14,
                  " - ",
                  str15,
                  "' WHERE baclength NOT IN('9992','WIRE MARKER') and BACREFDES1 ='",
                  str14,
                  "' AND BACREFDES2 ='",
                  str15,
                  "' AND BACPLID ='",
                  this.PLRER,
                  "'"
                }));
                                data2.ExecuteSQL(string.Concat(new string[] {
                  "UPDATE TBLCONT SET bacBraid ='B' WHERE BACREFDES1 ='",
                  str14,
                  "' AND BACREFDES2 ='",
                  str15,
                  "' AND BACPLID ='",
                  this.PLRER,
                  "'"
                }));
                                str6 = Conversions.ToString(Strings.Chr((Strings.Asc(str6) + 1)));
                            }
                        }
                        else
                        {
                            set2 = data2.getData(string.Concat(new string[] {
                "select distinct(left(bacwireno,",
                Conversions.ToString(index),
                ")) from tblcont WHERE bacWireSpec ='' and baclength NOT IN('9992','WIRE MARKER') and BACREFDES1 ='",
                str14,
                "' AND BACREFDES2 ='",
                str15,
                "' AND BACPLID ='",
                this.PLRER,
                "'"
              }));
                            if ((set2.Tables[0].Rows.Count != 0))
                            {
                                str13 = Conversions.ToString(set2.Tables[0].Rows[0][0]);
                                if ((set2.Tables[0].Rows.Count == 1))
                                {
                                    data2.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLCONT SET bacWireSpec ='",
                    str14,
                    " - ",
                    str15,
                    "' WHERE baclength NOT IN('9992','WIRE MARKER') and BACREFDES1 ='",
                    str14,
                    "' AND BACREFDES2 ='",
                    str15,
                    "' AND BACPLID ='",
                    this.PLRER,
                    "'"
                  }));
                                    data2.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLCONT SET bacBraid ='A' WHERE BACREFDES1 ='",
                    str14,
                    "' AND BACREFDES2 ='",
                    str15,
                    "' AND BACPLID ='",
                    this.PLRER,
                    "'"
                  }));
                                }
                                else
                                {
                                    if ((str6 == "W"))
                                    {
                                        str6 = "A";
                                        flag = true;
                                    }
                                    else if (flag)
                                    {
                                        str6 = Conversions.ToString(Strings.Chr((Strings.Asc(str6) + 1)));
                                    }
                                    else
                                    {
                                        str6 = Conversions.ToString(Strings.Chr((Strings.Asc(str6) + 1)));
                                    }
                                    if (flag)
                                    {
                                        data2.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLCONT SET bacWireSpec ='",
                      str14,
                      " - ",
                      str15,
                      "' WHERE baclength NOT IN('9992','WIRE MARKER') and BACREFDES1 ='",
                      str14,
                      "' AND BACREFDES2 ='",
                      str15,
                      "' AND BACPLID ='",
                      this.PLRER,
                      "'"
                    }));
                                        data2.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLCONT SET bacBraid ='A",
                      str6,
                      "' WHERE BACREFDES1 ='",
                      str14,
                      "' AND BACREFDES2 ='",
                      str15,
                      "' AND BACPLID ='",
                      this.PLRER,
                      "'"
                    }));
                                    }
                                    else
                                    {
                                        data2.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLCONT SET bacWireSpec ='",
                      str14,
                      " - ",
                      str15,
                      "' WHERE baclength NOT IN('9992','WIRE MARKER') and BACREFDES1 ='",
                      str14,
                      "' AND BACREFDES2 ='",
                      str15,
                      "' AND BACPLID ='",
                      this.PLRER,
                      "'"
                    }));
                                        data2.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLCONT SET bacBraid ='",
                      str6,
                      "' WHERE BACREFDES1 ='",
                      str14,
                      "' AND BACREFDES2 ='",
                      str15,
                      "' AND BACPLID ='",
                      this.PLRER,
                      "'"
                    }));
                                    }
                                }
                            }
                        }
                    }
                    str16 = str14;
                    str17 = str15;
                    k += 1;
                }
                data2.ExecuteSQL(("UPDATE TBLCONT SET bacWireSpec ='A' WHERE baclength NOT IN('9992','WIRE MARKER') and ((BACREFDES1 LIKE'%WT%') and (BACREFDES2 LIKE '%WT%')) AND BACPLID ='" + this.PLRER + "'"));
                data2.ExecuteSQL(("UPDATE TBLCONT SET bacBraid ='A' WHERE ((BACREFDES1 LIKE'%WT%') OR (BACREFDES2 LIKE '%WT%')) AND BACPLID ='" + this.PLRER + "'"));
                aset = data.getData(string.Concat(new string[] {
          "SELECT DISTINCT bacBraid,(bacWireNo),bacLength,bacWireSpec,WIRE_SPEC_GAGE FROM TBLCONT,PTP WHERE   bacPlId ='",
          this.PLRER,
          "' AND bacAction ='ADD' AND ((BACWIRENO NOT LIKE'%WHT%') AND (BACWIRENO NOT LIKE'%BLK%')) and bacWireno = WIRE_NUMBER and PART_NUMBER ='",
          this.GHARN,
          "'"
        }));
                DataRow[] source = aset.Tables[0].Select("bacLength ='9992'");
                int num26 = (source.Count() - 1);
                int m = 0;
                while ((m <= num26))
                {
                    row = source[m];
                    row[2] = "";
                    row[3] = "";
                    row[4] = "";
                    m += 1;
                }
                source = aset.Tables[0].Select("bacLength = '0012'");
                int num27 = (source.Count() - 1);
                int n = 0;
                while ((n <= num27))
                {
                    row = source[n];
                    row[3] = "X";
                    row[0] = "X";
                    n += 1;
                }
                source = aset.Tables[0].Select("bacLength ='WIRE MARKER'");
                int num28 = (source.Count() - 1);
                int num9 = 0;
                while ((num9 <= num28))
                {
                    row = source[num9];
                    row[4] = "";
                    row[3] = "X";
                    row[0] = "X";
                    num9 += 1;
                }
                source = aset.Tables[0].Select("bacLength ='9998'");
                int num29 = (source.Count() - 1);
                int num10 = 0;
                while ((num10 <= num29))
                {
                    row = source[num10];
                    row[2] = "WIRE MARKER";
                    row[3] = "X";
                    row[0] = "X";
                    row[4] = "";
                    num10 += 1;
                }
                source = aset.Tables[0].Select("bacLength ='WIRE MARKER' and bacWireNo like '%SH%'");
                int num30 = (source.Count() - 1);
                int num11 = 0;
                while ((num11 <= num30))
                {
                    row = source[num11];
                    row[3] = "";
                    num11 += 1;
                }
                DataSet set5 = new DataSet();
                source = aset.Tables[0].Select("WIRE_SPEC_GAGE <>''");
                int num31 = (source.Count() - 1);
                int num12 = 0;
                while ((num12 <= num31))
                {
                    row = source[num12];
                    string str10 = Conversions.ToString(row[4]);
                    if ((str10 == "C4928-20"))
                    {
                    }
                    set5 = data.getData(("SELECT * FROM PDFWIRE1 WHERE wspecOld ='" + str10 + "'"));
                    if ((set5.Tables[0].Rows.Count != 0))
                    {
                        string str9 = Conversions.ToString(set5.Tables[0].Rows[0][1]);
                        row[4] = str9;
                    }
                    num12 += 1;
                }
                aset.Tables[0].Columns.Add("LWA_LENGTH");
                source = aset.Tables[0].Select("bacBraid<>'A' and bacBraid<>'X'");
                int num32 = (source.Count() - 1);
                int num13 = 0;
                while ((num13 <= num32))
                {
                    row = source[num13];
                    str5 = Conversions.ToString(row[0]);
                    DataSet set7 = new DataSet();
                    str8 = Conversions.ToString(row[2]);
                    if (!(((str8 == "") | (str8 == null)) | (str8 == "WIRE MARKER")))
                    {
                        str8 = Conversions.ToString(data2.getData(string.Concat(new string[] {
              "SELECT MAX(BACLENGTH) FROM TBLCONT WHERE BACLENGTH <>'9992' AND BACPLID ='",
              this.PLRER,
              "' AND BACBRAID ='",
              str5,
              "'"
            })).Tables[0].Rows[0][0]);
                        try
                        {
                            str8 = Operators.AddObject(Conversion.Int(str8), 12).ToString().PadLeft(4, '0');//JMR -- look at ToString vs Conversions.ToString
                        }
                        catch (Exception exception6)
                        {
                            ProjectData.SetProjectError(exception6);
                            Exception exception2 = exception6;
                            ProjectData.ClearProjectError();
                        }
                    }
                    row[0] = ("Group " + str5 + " : Braid  together");
                    row[5] = str8;
                    num13 += 1;
                }
                source = aset.Tables[0].Select("bacBraid='A'");
                int num33 = (source.Count() - 1);
                int num14 = 0;
                while ((num14 <= num33))
                {
                    row = source[num14];
                    str8 = Conversions.ToString(row[2]);
                    try
                    {
                        str8 = Operators.AddObject(Conversion.Int(str8), 12).ToString().PadLeft(4, '0');//JMR -- look at ToString vs Conversions.ToString
                    }
                    catch (Exception exception7)
                    {
                        ProjectData.SetProjectError(exception7);
                        Exception exception3 = exception7;
                        ProjectData.ClearProjectError();
                    }
                    row[5] = str8;
                    str5 = Conversions.ToString(row[0]);
                    row[0] = ("Group " + str5 + " : Braid  Seperately");
                    num14 += 1;
                }
                source = aset.Tables[0].Select("bacBraid='X'");
                int num34 = (source.Count() - 1);
                int num15 = 0;
                while ((num15 <= num34))
                {
                    row = source[num15];
                    str8 = Conversions.ToString(row[2]);
                    try
                    {
                        str8 = Operators.AddObject(Conversion.Int(str8), 12).ToString().PadLeft(4, '0');//JMR -- look at ToString vs Conversions.ToString
                    }
                    catch (Exception exception8)
                    {
                        ProjectData.SetProjectError(exception8);
                        Exception exception4 = exception8;
                        str8 = str8;
                        ProjectData.ClearProjectError();
                    }
                    row[5] = str8;
                    str5 = Conversions.ToString(row[0]);
                    row[0] = ("Group " + str5 + " : No Braid");
                    num15 += 1;
                }

                source = aset.Tables[0].Select("bacBraid like 'Group A%' and bacWireNo like '%-1'");
                num34 = (source.Count() - 1);
                num15 = 0;
                while ((num15 <= num34))
                {
                    row = source[num15];
                    str8 = Conversions.ToString(row[1]);

                    try
                    {
                        DataRow[] source2QW;

                        source2QW = aset.Tables[0].Select("bacBraid NOT like 'Group A%' and bacWireNo = '" + str8.Substring(0, str8.Length - 1) + "2'");
                        ROQW = source2QW[0];
                        ROQW[0] = ("Group A : Braid  Seperately");
                        try
                        {
                            DataSet DFD = new DataSet();
                            DFD = data2.getData("SELECT BASEREF FROM TBLREFDES WHERE REFPLANID ='" + PlanNumber + "' AND REFDES IN (SELECT SREFDES AS REFDES FROM TBLWIRES WHERE SREFDES LIKE '%WT%' AND WIRENO ='" + str8 + "' AND WIRESPLID ='" + PlanNumber + "')");
                            string GFH;
                            GFH = DFD.Tables[0].Rows[0][0].ToString();//JMR -- added .ToString() -- look at ToString vs Conversions.ToString
                            row[3] = row[3] + " (NEAR " + GFH + ")";
                        }
                        catch (Exception ex)
                        {

                        }
                        //   row.Item(5) = 


                    }
                    catch (Exception exception8)
                    {
                        ProjectData.SetProjectError(exception8);
                        Exception exception4 = exception8;
                        //   str8 = str8
                        ProjectData.ClearProjectError();
                    }
                    try
                    {
                        DataRow[] source2QW;

                        source2QW = aset.Tables[0].Select("bacBraid NOT like 'Group A%' and bacWireNo = '" + str8.Substring(0, str8.Length - 1) + "3'");
                        ROQW = source2QW[0];
                        ROQW[0] = ("Group A : Braid  Seperately");



                    }
                    catch (Exception exception8)
                    {
                        ProjectData.SetProjectError(exception8);
                        Exception exception4 = exception8;
                        //   str8 = str8
                        ProjectData.ClearProjectError();
                    }


                    num15 += 1;
                }
                try
                {
                    source = aset.Tables[0].Select("bacBraid like 'Group  : Braid  together' and bacWireNo like '%SH%'");
                    num34 = (source.Count() - 1);
                    num15 = 0;
                    while ((num15 <= num34))
                    {
                        row = source[num15];
                        str8 = Conversions.ToString(row[1]);
                        str8 = str8.Substring(0, (str8.Length - 5));
                        DataSet DF = new DataSet();
                        DataRow[] source2QW;
                        source2QW = aset.Tables[0].Select("bacBraid NOT like 'Group  : Braid  together' and bacWireNo like '" + str8 + "%'");
                        string FHG;
                        DataRow ROWD;
                        ROWD = source2QW[0];
                        FHG = Conversions.ToString(ROWD[0]);
                        row[0] = FHG;
                        num15 += 1;
                        aset.AcceptChanges();

                    }
                }
                catch (Exception ex)
                {

                }

                // MANUFACTURING INSTRUCTIONS FOR LWA H16DW1606-


                //dgroup.Label2.Text = String.Concat(New String() {me.gharn.Substring(0, me.gharn.IndexOf("-")), " from ", me.gharnold.Substring(me.gharnold.IndexOf("-")), " to ", me.gharn.Substring(me.gharn.IndexOf("-")), " ( LWA ", me.gharn.Substring(0, me.gharn.IndexOf("-")), "-", Me.txtTbd.Text, ")"})
                //dgroup.ShowPreview()
                aset.Tables[0].Columns["WIRE_SPEC_GAGE"].SetOrdinal(2);
                aset.Tables[0].Columns["LWA_LENGTH"].SetOrdinal(3);


                aset.Tables[0].Columns["bacLength"].SetOrdinal(4);
                aset.Tables[0].Columns[1].ColumnName = "WIRE NUMBER";
                aset.Tables[0].Columns[4].ColumnName = "ENG_LENGTH";
                aset.Tables[0].Columns[3].ColumnName = "LENGTH (IN)";
                aset.Tables[0].Columns[2].ColumnName = "WIRE_SPEC_GAGE";
                aset.Tables[0].Columns[5].ColumnName = "END1 - END2";

                iselectrical = true;
                aset.AcceptChanges();
                ExportToExcel50(set78.Tables[0], aset.Tables[0], aset.Tables[0]);
                //Exit Select
                //    Case 1
                //source = aset.Tables.Item(0).[Select]("bacWireSpec =''")
                //Dim num36 As Integer = (source.Count - 1)
                //Dim num16 As Integer = 0
                //Do While (num16 <= num36)
                //    row = source(num16)
                //    row.Item(1) = ""
                //    row.Item(2) = ""
                //    row.Item(3) = ""
                //    num16 += 1
                //Loop
                //source = aset.Tables.Item(0).[Select]("bacWireSpec <>''")
                //Dim num37 As Integer = (source.Count - 1)
                //Dim num17 As Integer = 0
                //Do While (num17 <= num37)
                //    row = source(num17)
                //    Dim str18 As String = Conversions.ToString(row.Item(4))
                //    Try
                //        str18 = str18.Substring(6, (str18.IndexOf(":") - 6)).Trim
                //    Catch exception9 As Exception
                //        ProjectData.SetProjectError(exception9)
                //        Dim exception5 As Exception = exception9
                //        str18 = ""
                //        ProjectData.ClearProjectError()
                //    End Try
                //    row.Item(2) = str18
                //    num17 += 1
                //Loop
                //dno.grdBraid.DataSource = aset.Tables.Item(0)
                //dno.XrLabel2.Text = String.Concat(New String() {"From ", Me.GHARNOLD, " to ", Me.GHARN, ". "})
                //dno.XrLabel2.Text = String.Concat(New String() {Me.GHARN.Substring(0, Me.GHARN.IndexOf("-")), " from ", Me.GHARNOLD.Substring(Me.GHARNOLD.IndexOf("-")), " to ", Me.GHARN.Substring(Me.GHARN.IndexOf("-")), " ( LWA ", Me.GHARN.Substring(0, Me.GHARN.IndexOf("-")), "-", Me.cardtbd, ")"})
                //Dim set8 As New DataSet
                //set8 = data2.getData(("select distinct bacBraid from tblcont where bacPlId ='" & Me.PLRER & "'"))
                //source = set8.Tables.Item(0).[Select]("bacBraid<>'A' and bacBraid<>'X' and bacbraid <>''")
                //Dim num38 As Integer = (source.Count - 1)
                //Dim num18 As Integer = 0
                //Do While (num18 <= num38)
                //    row = source(num18)
                //    str5 = Conversions.ToString(row.Item(0))
                //    row.Item(0) = ("Group " & str5 & " : Braid wires together")
                //    num18 += 1
                //Loop
                //source = set8.Tables.Item(0).[Select]("bacBraid='A'")
                //Dim num39 As Integer = (source.Count - 1)
                //Dim num19 As Integer = 0
                //Do While (num19 <= num39)
                //    row = source(num19)
                //    str5 = Conversions.ToString(row.Item(0))
                //    row.Item(0) = ("Group " & str5 & " : Braid wires seperately")
                //    num19 += 1
                //Loop
                //source = set8.Tables.Item(0).[Select]("bacBraid='X'")
                //Dim num40 As Integer = (source.Count - 1)
                //Dim num20 As Integer = 0
                //Do While (num20 <= num40)
                //    row = source(num20)
                //    str5 = Conversions.ToString(row.Item(0))
                //    row.Item(0) = ("Group " & str5 & " : No Braid")
                //    num20 += 1
                //Loop
                //source = set8.Tables.Item(0).[Select]("bacBraid = ' '")
                //Dim num41 As Integer = (source.Count - 1)
                //Dim num21 As Integer = 0
                //Do While (num21 <= num41)
                //    row = source(num21)
                //    str5 = Conversions.ToString(row.Item(0))
                //    row.Item(0) = "Group X : No Braid"
                //    num21 += 1
                //Loop
                //dno.grdInstr.DataSource = set8.Tables.Item(0)
                //dno.ShowPreview()
                //Exit Select
                //End Select
            }

        }

        private void  // ERROR: Handles clauses are not supported in C#
    ComboBoxEdit1_SelectedIndexChanged(System.Object sender, System.EventArgs e)
        {

            //Dim GHARN As String
            //Dim GHARNOLD As String
            //Dim PLRER As String
            //Dim carddesc As String
            //Dim cardtbd As String
            //Dim cardnopl As String
            try
            {
                cardnopl = cmbCards.SelectedItem.ToString();//JMR -- look at -- added ToString -- check out ToString vs Conversions.ToString

                clsData clsd = new clsData();
                DataSet dsca = new DataSet();
                dsca = clsd.getData("SELECT * FROM TBLGENERAL WHERE GENPLANNUMBER ='" + cardnopl + "'");
                PLRER = dsca.Tables[0].Rows[0]["genplid"].ToString();//JMR -- look at -- added ToString -- check out ToString vs Conversions.ToString
                carddesc = dsca.Tables[0].Rows[0]["genDescription"].ToString();//JMR -- look at -- added ToString -- check out ToString vs Conversions.ToString
                //cardtbd = IIf(dsca.Tables(0).Rows(0).Item("genPdf1"), IsDBNull.Value, "")

                cardtbd = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(dsca.Tables[0].Rows[0]["genPdf1"], DBNull.Value)), "TBD", RuntimeHelpers.GetObjectValue(dsca.Tables[0].Rows[0]["genPdf1"])));
                CARDTypeVer = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(dsca.Tables[0].Rows[0]["genTypeVer"], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(dsca.Tables[0].Rows[0]["genTypeVer"])));
                DataSet aset = new DataSet();
                SimpleButton8.Enabled = true;
                aset = clsd.getData(("SELECT * FROM TBLSELHARNESS WHERE hrnSelPlId ='" + PLRER + "'"));
                if (((object.ReferenceEquals(aset.Tables[0].Rows, DBNull.Value)) | (aset.Tables[0].Rows.Count == 0)))
                {

                    this.GHARNOLD = "";
                    this.GHARN = "";
                    SimpleButton9.Enabled = false;
                }
                else
                {
                    this.GHARNOLD = Conversions.ToString(aset.Tables[0].Rows[0]["OldHrn"]);
                    this.GHARN = Conversions.ToString(aset.Tables[0].Rows[0]["NewHrn"]);
                    Module1.newModule.oldharn = this.GHARNOLD;
                    Module1.newModule.newharn = this.GHARN;
                    //Module1.fillOldHarness(Me.grdOld, Me.NEWHARNESSPTP, Me.GHARNOLD)
                    int num3 = (this.GHARN.IndexOf("-") + 1);
                    if (cardnopl.StartsWith("50"))
                    {
                        SimpleButton9.Enabled = true;
                    }
                    else if (!cardnopl.StartsWith("50"))
                    {
                        SimpleButton9.Enabled = false;
                    }


                }
            }
            catch (Exception ex)
            {

            }


        }
        private void ExportToExcel50(System.Data.DataTable objDT, System.Data.DataTable objDT2, System.Data.DataTable objDT3)
        {
            //object Excel = CreateObject("Excel.Application");
            //object Excel = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"));//JMR replaced above line 'quick and dirty way'//second attempt
            Microsoft.Office.Interop.Excel._Application Excel = new Microsoft.Office.Interop.Excel.Application();//JMR -- third attempt
            string strFilename = "";//JMR -- nulled it
            int intCol;
            int intRow;
            string strPath = "c:\\";
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.InitialDirectory = "Desktop";

            DataView DFG;
            if (isMKPL)
            {

            }
            else if (iselectrical)
            {
                objDT2.DefaultView.Sort = "bacBraid ASC";
                objDT2.AcceptChanges();
                dlg.FileName = GHARN.Substring(4, GHARN.IndexOf("-") - 4) + " ELECTRICAL PLANNING";
                dlg.CheckFileExists = false;
                DFG = new DataView(objDT2);
                DFG.Sort = "bacBraid asc,[WIRE NUMBER]";

            }
            if (isMKPL)
            {
                dlg.FileName = GHARN.Substring(4, GHARN.IndexOf("-") - 4) + " MKPL";
                dlg.CheckFileExists = false;
            }

            dlg.Filter = "Microsoft Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";

            if (Excel == null)
            {
                //MsgBox("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", MsgBoxStyle.Critical);
                XtraMessageBox.Show("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", "ERROR");//JMR -- commented out above and changed it to this
                return;
            }
            try
            {
                // ERROR: Not supported in C#: WithStatement





                Excel = null;
                // MsgBox("Data's are exported to Excel Succesfully in '" & strFilename & "'", MsgBoxStyle.Information)
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Cannot access "))
                {
                    strFilename = ((strFilename.Substring(0, (strFilename.Length - 5))) + "new.xlsx");
                    Excel.ActiveCell.Worksheet.SaveAs(strFilename);
                    Excel.Workbooks.Open(strFilename);
                    Excel.Visible = true;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel);
                    //MsgBox("File saved as " + strFilename);
                    XtraMessageBox.Show("File saved as " + strFilename);//JMR -- commented out above line and changed it to this one
                }
                else
                {

                    XtraMessageBox.Show(ex.Message);//JMR -- changed MsgBox to XtraMessageBox.Show
                }


            }
            // The excel is created and opened for insert value. We most close this excel using this system


        }
        private void ExportToExcel30(System.Data.DataTable objDT, System.Data.DataTable objDT2, System.Data.DataTable objDT3)
        {
            //object Excel = CreateObject("Excel.Application");
            //object Excel = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"));//JMR replaced above line 'quick and dirty way' // second attempt
            Microsoft.Office.Interop.Excel._Application Excel = new Microsoft.Office.Interop.Excel.Application();//JMR -- Third attempt
            string strFilename = "";//JMR -- nulled it
            int intCol;
            int intRow;
            string strPath = "c:\\";
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.InitialDirectory = "Desktop";
            dlg.Filter = "Microsoft Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
            try
            {
                dlg.FileName = GHARN.Substring(4, GHARN.IndexOf("-") - 4) + " MKPL";
            }
            catch (Exception ex)
            {
                dlg.FileName = ("MKPL");
            }
            if (Excel == null)
            {
                //MsgBox("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", MsgBoxStyle.Critical);
                XtraMessageBox.Show("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", "ERROR");//JMR -- Commented out above lined and changed it to this one
                return;
            }
            try
            {
                // ERROR: Not supported in C#: WithStatement





                Excel = null;
                // MsgBox("Data's are exported to Excel Succesfully in '" & strFilename & "'", MsgBoxStyle.Information)
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Cannot access "))
                {
                    strFilename = ((strFilename.Substring(0, (strFilename.Length - 5))) + "new.xlsx");
                    Excel.ActiveCell.Worksheet.SaveAs(strFilename);
                    Excel.Workbooks.Open(strFilename);
                    Excel.Visible = true;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel);
                    XtraMessageBox.Show("File saved as " + strFilename);//JMR -- Changed MsgBox to XtraMessageBox.Show
                }
                else
                {

                    XtraMessageBox.Show(ex.Message);//JMR -- Changed MsgBox to XtraMessageBox.Show
                }
            }
            // The excel is created and opened for insert value. We most close this excel using this system


        }
        private void ExportToExcel(System.Data.DataTable objDT, System.Data.DataTable objDT2, System.Data.DataTable objDT3)
        {
            //object Excel = CreateObject("Excel.Application");
            object Excel = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"));//JMR replaced above line 'quick and dirty way'
            string strFilename;
            int intCol;
            int intRow;
            string strPath = "c:\\";
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.InitialDirectory = "Desktop";
            dlg.Filter = "Microsoft Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
            try
            {
                dlg.FileName = ("MKPL FOR  " + carddesc);
            }
            catch (Exception ex)
            {
                dlg.FileName = "MKPL";
            }
            if (Excel == null)
            {
                //MsgBox("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", MsgBoxStyle.Critical);
                XtraMessageBox.Show("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", "ERROR");//JMR -- Commented out above line and changed it to this one
                return;
            }
            try
            {
                // ERROR: Not supported in C#: WithStatement





                Excel = null;
                // MsgBox("Data's are exported to Excel Succesfully in '" & strFilename & "'", MsgBoxStyle.Information)
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);//JMR -- Changed MsgBox to XtraMessageBox.Show
            }
            // The excel is created and opened for insert value. We most close this excel using this system


        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton10_Click(System.Object sender, System.EventArgs e)
        {
            DataSet set2 = new DataSet();
            clsData data2 = new clsData();
            set2 = data2.getData("SELECT * FROM TBLREFDES WHERE reportnote not like '%reidentify%' and reportnote not like '%c8844%' AND reportnote LIKE '%tubing%'");
            int num94 = (set2.Tables[0].Rows.Count - 1);
            int i4 = 0;
            string rep = "";
            string cardn;
            string newrep;
            while ((i4 <= num94))
            {
                Module1.newModule.RefDes = Conversions.ToString(set2.Tables[0].Rows[i4]["REFDES"]);
                rep = Conversions.ToString(set2.Tables[0].Rows[i4]["refplanid"]);

                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblgeneral SET gencomparison ='kl' WHERE genplid ='",
          rep,
          "'"
        }));
                i4 += 1;
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    NavBarGroupControlContainer3_Click(System.Object sender, System.EventArgs e)
        {

        }

        private void frmMain_Load_1(object sender, EventArgs e)
        {

        }

        private void frmMain_Load(object sender, EventArgs e)
        {

        }

        private void txtCountry_EditValueChanged(object sender, EventArgs e)
        {

        }

        private void cmbProgram_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void frmMain_Load()
        {

        }
    }
}

